Search in sources :

Example 66 with YearMonth

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

the class TCKYearMonth method test_with_Year_noChange_equal.

@Test
public void test_with_Year_noChange_equal() {
    YearMonth test = YearMonth.of(2008, 6);
    assertEquals(test.with(Year.of(2008)), test);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 67 with YearMonth

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

the class TCKYearMonth method now_ZoneId.

@Test
public void now_ZoneId() {
    ZoneId zone = ZoneId.of("UTC+01:02:03");
    YearMonth expected = YearMonth.now(Clock.system(zone));
    YearMonth test = YearMonth.now(zone);
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = YearMonth.now(Clock.system(zone));
        test = YearMonth.now(zone);
    }
    assertEquals(test, expected);
}
Also used : ZoneId(java.time.ZoneId) YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 68 with YearMonth

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

the class TCKYearMonth method factory_intsMonth.

//-----------------------------------------------------------------------
@Test
public void factory_intsMonth() {
    YearMonth test = YearMonth.of(2008, Month.FEBRUARY);
    check(test, 2008, 2);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 69 with YearMonth

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

the class TCKYearMonth method test_until_invalidType.

@Test(expectedExceptions = DateTimeException.class)
public void test_until_invalidType() {
    YearMonth start = YearMonth.of(2010, 6);
    start.until(LocalTime.of(11, 30), MONTHS);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 70 with YearMonth

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

the class TCKYearMonth method test_withYear_tooLow.

@Test(expectedExceptions = DateTimeException.class)
public void test_withYear_tooLow() {
    YearMonth test = YearMonth.of(2008, 6);
    test.withYear(Year.MIN_VALUE - 1);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Aggregations

YearMonth (java.time.YearMonth)85 Test (org.testng.annotations.Test)78 LocalDate (java.time.LocalDate)8 IOException (java.io.IOException)5 DateTimeException (java.time.DateTimeException)5 DateTimeParseException (java.time.format.DateTimeParseException)4 UnsupportedTemporalTypeException (java.time.temporal.UnsupportedTemporalTypeException)4 Instant (java.time.Instant)2 ChronoLocalDate (java.time.chrono.ChronoLocalDate)2 Chronology (java.time.chrono.Chronology)2 Clock (java.time.Clock)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 Month (java.time.Month)1 MonthDay (java.time.MonthDay)1 OffsetDateTime (java.time.OffsetDateTime)1 OffsetTime (java.time.OffsetTime)1 Year (java.time.Year)1 ZoneId (java.time.ZoneId)1 ZonedDateTime (java.time.ZonedDateTime)1