Search in sources :

Example 26 with YearMonth

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

the class TCKYearMonth method test_minusMonths_long_invalidTooLargeMaxSubtractMin.

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

Example 27 with YearMonth

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

the class TCKYearMonth method test_isValidDay_int_febNonLeap.

@Test
public void test_isValidDay_int_febNonLeap() {
    YearMonth test = YearMonth.of(2007, 2);
    assertEquals(test.isValidDay(1), true);
    assertEquals(test.isValidDay(28), true);
    assertEquals(test.isValidDay(-1), false);
    assertEquals(test.isValidDay(0), false);
    assertEquals(test.isValidDay(29), false);
    assertEquals(test.isValidDay(32), false);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 28 with YearMonth

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

the class TCKYearMonth method test_equals.

//-----------------------------------------------------------------------
// equals()
//-----------------------------------------------------------------------
@Test
public void test_equals() {
    YearMonth a = YearMonth.of(2008, 6);
    YearMonth b = YearMonth.of(2008, 6);
    YearMonth c = YearMonth.of(2007, 6);
    YearMonth d = YearMonth.of(2008, 5);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), true);
    assertEquals(a.equals(c), false);
    assertEquals(a.equals(d), false);
    assertEquals(b.equals(a), true);
    assertEquals(b.equals(b), true);
    assertEquals(b.equals(c), false);
    assertEquals(b.equals(d), false);
    assertEquals(c.equals(a), false);
    assertEquals(c.equals(b), false);
    assertEquals(c.equals(c), true);
    assertEquals(c.equals(d), false);
    assertEquals(d.equals(a), false);
    assertEquals(d.equals(b), false);
    assertEquals(d.equals(c), false);
    assertEquals(d.equals(d), true);
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 29 with YearMonth

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

the class TCKYearMonth method test_plusYears_long_invalidTooLarge.

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

Example 30 with YearMonth

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

the class TCKYearMonth method test_minusMonths_long_negative.

@Test
public void test_minusMonths_long_negative() {
    YearMonth test = YearMonth.of(2008, 6);
    assertEquals(test.minusMonths(-1), YearMonth.of(2008, 7));
}
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