use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_with_adjustment.
//-----------------------------------------------------------------------
// with()
//-----------------------------------------------------------------------
@Test
public void test_with_adjustment() {
final LocalDateTime sample = LocalDateTime.of(2012, 3, 4, 23, 5);
TemporalAdjuster adjuster = new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return sample;
}
};
assertEquals(TEST_2007_07_15_12_30_40_987654321.with(adjuster), sample);
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKChronoPeriod method test_addTo.
//-----------------------------------------------------------------------
@Test(dataProvider = "calendars")
public void test_addTo(Chronology chrono) {
ChronoPeriod period = chrono.period(1, 2, 3);
ChronoLocalDate date = chrono.dateNow();
Temporal result = period.addTo(date);
assertEquals(result, date.plus(14, MONTHS).plus(3, DAYS));
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKChronoPeriod method test_subtractFrom.
@Test(dataProvider = "calendars")
public void test_subtractFrom(Chronology chrono) {
ChronoPeriod period = chrono.period(1, 2, 3);
ChronoLocalDate date = chrono.dateNow();
Temporal result = period.subtractFrom(date);
assertEquals(result, date.minus(14, MONTHS).minus(3, DAYS));
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKLocalDate method test_with_adjustment.
//-----------------------------------------------------------------------
// with()
//-----------------------------------------------------------------------
@Test
public void test_with_adjustment() {
final LocalDate sample = LocalDate.of(2012, 3, 4);
TemporalAdjuster adjuster = new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return sample;
}
};
assertEquals(TEST_2007_07_15.with(adjuster), sample);
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_adjustInto.
@Test(dataProvider = "adjustInto")
public void test_adjustInto(LocalTime test, Temporal temporal, Temporal expected, Class<?> expectedEx) {
if (expectedEx == null) {
Temporal result = test.adjustInto(temporal);
assertEquals(result, expected);
} else {
try {
Temporal result = test.adjustInto(temporal);
fail();
} catch (Exception ex) {
assertTrue(expectedEx.isInstance(ex));
}
}
}
Aggregations