Search in sources :

Example 6 with Year

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

the class TCKYear method test_equals.

//-----------------------------------------------------------------------
// equals() / hashCode()
//-----------------------------------------------------------------------
@Test
public void test_equals() {
    for (int i = -4; i <= 2104; i++) {
        Year a = Year.of(i);
        for (int j = -4; j <= 2104; j++) {
            Year b = Year.of(j);
            assertEquals(a.equals(b), i == j);
            assertEquals(a.hashCode() == b.hashCode(), i == j);
        }
    }
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 7 with Year

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

the class TCKYear method test_until_convertedType.

@Test
public void test_until_convertedType() {
    Year start = Year.of(2010);
    YearMonth end = start.plusYears(2).atMonth(Month.APRIL);
    assertEquals(start.until(end, YEARS), 2);
}
Also used : Year(java.time.Year) YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 8 with Year

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

the class TCKYear method test_atMonth_int_invalidMonth.

@Test(expectedExceptions = DateTimeException.class)
public void test_atMonth_int_invalidMonth() {
    Year test = Year.of(2008);
    test.atMonth(13);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 9 with Year

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

the class TCKYear method now.

//-----------------------------------------------------------------------
// now()
//-----------------------------------------------------------------------
@Test
public void now() {
    Year expected = Year.now(Clock.systemDefaultZone());
    Year test = Year.now();
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = Year.now(Clock.systemDefaultZone());
        test = Year.now();
    }
    assertEquals(test, expected);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 10 with Year

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

the class TCKYear method test_equals_incorrectType.

@Test
public void test_equals_incorrectType() {
    Year test = Year.of(1);
    assertEquals(test.equals("Incorrect type"), false);
}
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