Search in sources :

Example 21 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_equals_same.

@Test
public void test_equals_same() {
    Year test = Year.of(2011);
    assertEquals(test.equals(test), true);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 22 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_atDay_day367.

@Test(expectedExceptions = DateTimeException.class)
public void test_atDay_day367() {
    Year test = Year.of(2007);
    test.atDay(367);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 23 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_compareTo.

//-----------------------------------------------------------------------
// compareTo()
//-----------------------------------------------------------------------
@Test
public void test_compareTo() {
    for (int i = -4; i <= 2104; i++) {
        Year a = Year.of(i);
        for (int j = -4; j <= 2104; j++) {
            Year b = Year.of(j);
            if (i < j) {
                assertEquals(a.compareTo(b) < 0, true);
                assertEquals(b.compareTo(a) > 0, true);
                assertEquals(a.isAfter(b), false);
                assertEquals(a.isBefore(b), true);
                assertEquals(b.isAfter(a), true);
                assertEquals(b.isBefore(a), false);
            } else if (i > j) {
                assertEquals(a.compareTo(b) > 0, true);
                assertEquals(b.compareTo(a) < 0, true);
                assertEquals(a.isAfter(b), true);
                assertEquals(a.isBefore(b), false);
                assertEquals(b.isAfter(a), false);
                assertEquals(b.isBefore(a), true);
            } else {
                assertEquals(a.compareTo(b), 0);
                assertEquals(b.compareTo(a), 0);
                assertEquals(a.isAfter(b), false);
                assertEquals(a.isBefore(b), false);
                assertEquals(b.isAfter(a), false);
                assertEquals(b.isBefore(a), false);
            }
        }
    }
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 24 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_atDay_notLeapYear_day366.

@Test(expectedExceptions = DateTimeException.class)
public void test_atDay_notLeapYear_day366() {
    Year test = Year.of(2007);
    test.atDay(366);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 25 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_atDay_day0.

@Test(expectedExceptions = DateTimeException.class)
public void test_atDay_day0() {
    Year test = Year.of(2007);
    test.atDay(0);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Aggregations

Year (java.time.Year)34 Test (org.testng.annotations.Test)33 LocalDate (java.time.LocalDate)3 YearMonth (java.time.YearMonth)2 Clock (java.time.Clock)1 DateTimeException (java.time.DateTimeException)1 Instant (java.time.Instant)1 ZoneId (java.time.ZoneId)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 DateTimeParseException (java.time.format.DateTimeParseException)1 Temporal (java.time.temporal.Temporal)1 TemporalAccessor (java.time.temporal.TemporalAccessor)1 UnsupportedTemporalTypeException (java.time.temporal.UnsupportedTemporalTypeException)1