Search in sources :

Example 16 with YearMonth

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

the class TCKYearMonth method test_with_Month_noChange_equal.

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

Example 17 with YearMonth

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

the class TCKYearMonth method test_plusMonths_long_invalidTooLargeMaxAddMin.

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

Example 18 with YearMonth

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

the class TCKYearMonth method test_minusYears_long_invalidTooLargeMaxSubtractMin.

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

Example 19 with YearMonth

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

the class TCKYearMonth method test_adjustDate.

//-----------------------------------------------------------------------
// adjustInto()
//-----------------------------------------------------------------------
@Test
public void test_adjustDate() {
    YearMonth test = YearMonth.of(2008, 6);
    LocalDate date = LocalDate.of(2007, 1, 1);
    assertEquals(test.adjustInto(date), LocalDate.of(2008, 6, 1));
}
Also used : YearMonth(java.time.YearMonth) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 20 with YearMonth

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

the class TCKYearMonth method factory_parse_formatter.

//-----------------------------------------------------------------------
// parse(DateTimeFormatter)
//-----------------------------------------------------------------------
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y M");
    YearMonth test = YearMonth.parse("2010 12", f);
    assertEquals(test, YearMonth.of(2010, 12));
}
Also used : YearMonth(java.time.YearMonth) DateTimeFormatter(java.time.format.DateTimeFormatter) 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