Search in sources :

Example 36 with YearMonth

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

the class TCKYearMonth method test_minusMonths_long_invalidTooLarge.

@Test(expectedExceptions = { DateTimeException.class })
public void test_minusMonths_long_invalidTooLarge() {
    YearMonth test = YearMonth.of(Year.MAX_VALUE, 12);
    test.minusMonths(-1);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 37 with YearMonth

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

the class TCKYearMonth method test_withYear.

//-----------------------------------------------------------------------
// withYear()
//-----------------------------------------------------------------------
@Test
public void test_withYear() {
    YearMonth test = YearMonth.of(2008, 6);
    assertEquals(test.withYear(1999), YearMonth.of(1999, 6));
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 38 with YearMonth

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

the class TCKYearMonth method test_minus_TemporalAmount.

@Test(dataProvider = "minus_TemporalAmount")
public void test_minus_TemporalAmount(YearMonth base, TemporalAmount temporalAmount, YearMonth expectedYearMonth, Class<?> expectedEx) {
    if (expectedEx == null) {
        assertEquals(base.minus(temporalAmount), expectedYearMonth);
    } else {
        try {
            YearMonth result = base.minus(temporalAmount);
            fail();
        } catch (Exception ex) {
            assertTrue(expectedEx.isInstance(ex));
        }
    }
}
Also used : YearMonth(java.time.YearMonth) DateTimeException(java.time.DateTimeException) DateTimeParseException(java.time.format.DateTimeParseException) IOException(java.io.IOException) UnsupportedTemporalTypeException(java.time.temporal.UnsupportedTemporalTypeException) Test(org.testng.annotations.Test)

Example 39 with YearMonth

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

the class TCKYearMonth method test_lengthOfMonth_febLeap.

@Test
public void test_lengthOfMonth_febLeap() {
    YearMonth test = YearMonth.of(2008, 2);
    assertEquals(test.lengthOfMonth(), 29);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 40 with YearMonth

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

the class TCKYearMonth method test_plusYears_long_invalidTooLargeMaxAddMax.

@Test(expectedExceptions = DateTimeException.class)
public void test_plusYears_long_invalidTooLargeMaxAddMax() {
    YearMonth test = YearMonth.of(Year.MAX_VALUE, 12);
    test.plusYears(Long.MAX_VALUE);
}
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