Search in sources :

Example 56 with YearMonth

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

the class TCKYearMonth method test_until_convertedType.

@Test
public void test_until_convertedType() {
    YearMonth start = YearMonth.of(2010, 6);
    LocalDate end = start.plusMonths(2).atDay(12);
    assertEquals(start.until(end, MONTHS), 2);
}
Also used : YearMonth(java.time.YearMonth) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 57 with YearMonth

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

the class TCKYearMonth method test_with_Year.

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

Example 58 with YearMonth

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

the class TCKYearMonth method test_plusYears_long_negative.

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

Example 59 with YearMonth

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

the class TCKYearMonth method test_minusYears_long_negative.

@Test
public void test_minusYears_long_negative() {
    YearMonth test = YearMonth.of(2008, 6);
    assertEquals(test.minusYears(-1), YearMonth.of(2009, 6));
}
Also used : YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 60 with YearMonth

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

the class TCKYearMonth method test_minusMonths_long_big.

@Test
public void test_minusMonths_long_big() {
    YearMonth test = YearMonth.of(40, 6);
    long months = 20L + Integer.MAX_VALUE;
    assertEquals(test.minusMonths(months), YearMonth.of((int) (40L - months / 12), 6 - (int) (months % 12)));
}
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