Search in sources :

Example 11 with Year

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

the class TCKYear method now_Clock.

//-----------------------------------------------------------------------
// now(Clock)
//-----------------------------------------------------------------------
@Test
public void now_Clock() {
    Instant instant = OffsetDateTime.of(LocalDate.of(2010, 12, 31), LocalTime.of(0, 0), ZoneOffset.UTC).toInstant();
    Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
    Year test = Year.now(clock);
    assertEquals(test.getValue(), 2010);
}
Also used : Year(java.time.Year) Instant(java.time.Instant) Clock(java.time.Clock) Test(org.testng.annotations.Test)

Example 12 with Year

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

the class TCKYear method test_compareTo_nullYear.

@Test(expectedExceptions = NullPointerException.class)
public void test_compareTo_nullYear() {
    Year doy = null;
    Year test = Year.of(1);
    test.compareTo(doy);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 13 with Year

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

the class TCKYear method test_adjustDate_resolve.

@Test
public void test_adjustDate_resolve() {
    Year test = Year.of(2011);
    assertEquals(test.adjustInto(LocalDate.of(2012, 2, 29)), LocalDate.of(2011, 2, 28));
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 14 with Year

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

the class TCKYear method test_atMonthDay_nullMonthDay.

@Test(expectedExceptions = NullPointerException.class)
public void test_atMonthDay_nullMonthDay() {
    Year test = Year.of(2008);
    test.atMonthDay((MonthDay) null);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 15 with Year

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

the class TCKYear method test_atDay_notLeapYear.

//-----------------------------------------------------------------------
// atDay(int)
//-----------------------------------------------------------------------
@Test
public void test_atDay_notLeapYear() {
    Year test = Year.of(2007);
    LocalDate expected = LocalDate.of(2007, 1, 1);
    for (int i = 1; i <= 365; i++) {
        assertEquals(test.atDay(i), expected);
        expected = expected.plusDays(1);
    }
}
Also used : Year(java.time.Year) LocalDate(java.time.LocalDate) 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