Search in sources :

Example 41 with YearMonth

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

the class TCKYearMonth method test_minus_long_TemporalUnit.

@Test(dataProvider = "minus_long_TemporalUnit")
public void test_minus_long_TemporalUnit(YearMonth base, long amount, TemporalUnit unit, YearMonth expectedYearMonth, Class<?> expectedEx) {
    if (expectedEx == null) {
        assertEquals(base.minus(amount, unit), expectedYearMonth);
    } else {
        try {
            YearMonth result = base.minus(amount, unit);
            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 42 with YearMonth

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

the class TCKYearMonth method test_withYear_int_noChange_equal.

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

Example 43 with YearMonth

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

the class TCKYear method test_until_convertedType.

@Test
public void test_until_convertedType() {
    Year start = Year.of(2010);
    YearMonth end = start.plusYears(2).atMonth(Month.APRIL);
    assertEquals(start.until(end, YEARS), 2);
}
Also used : Year(java.time.Year) YearMonth(java.time.YearMonth) Test(org.testng.annotations.Test)

Example 44 with YearMonth

use of java.time.YearMonth in project JFoenix by jfoenixadmin.

the class JFXDatePickerContent method updateMonthYearPane.

protected void updateMonthYearPane() {
    // update date labels
    YearMonth yearMonth = selectedYearMonth.get();
    if (datePicker.getValue() != null)
        selectedDateLabel.setText(DateTimeFormatter.ofPattern("EEE, MMM yy").format(datePicker.getValue()));
    else
        selectedDateLabel.setText(DateTimeFormatter.ofPattern("EEE, MMM yy").format(LocalDate.now()));
    selectedYearLabel.setText(formatYear(yearMonth));
    monthYearLabel.setText(formatMonth(yearMonth) + " " + formatYear(yearMonth));
    Chronology chrono = datePicker.getChronology();
    LocalDate firstDayOfMonth = yearMonth.atDay(1);
    backMonthButton.setDisable(!isValidDate(chrono, firstDayOfMonth, -1, DAYS));
    forwardMonthButton.setDisable(!isValidDate(chrono, firstDayOfMonth, +1, MONTHS));
}
Also used : YearMonth(java.time.YearMonth) Chronology(java.time.chrono.Chronology) ChronoLocalDate(java.time.chrono.ChronoLocalDate) LocalDate(java.time.LocalDate)

Example 45 with YearMonth

use of java.time.YearMonth in project wildfly by wildfly.

the class YearMonthExternalizer method readObject.

@Override
public YearMonth readObject(ObjectInput input) throws IOException, ClassNotFoundException {
    int year = input.readInt();
    Month month = MonthExternalizer.INSTANCE.readObject(input);
    return YearMonth.of(year, month);
}
Also used : Month(java.time.Month) YearMonth(java.time.YearMonth)

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