use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_with_adjustment_AmPm.
@Test
public void test_with_adjustment_AmPm() {
OffsetTime test = TEST_11_30_59_500_PONE.with(new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return dateTime.with(HOUR_OF_DAY, 23);
}
});
assertEquals(test, OffsetTime.of(23, 30, 59, 500, OFFSET_PONE));
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_with_adjustment.
//-----------------------------------------------------------------------
// with(WithAdjuster)
//-----------------------------------------------------------------------
@Test
public void test_with_adjustment() {
final OffsetTime sample = OffsetTime.of(23, 5, 0, 0, OFFSET_PONE);
TemporalAdjuster adjuster = new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return sample;
}
};
assertEquals(TEST_11_30_59_500_PONE.with(adjuster), sample);
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKYear method test_adjustDate.
//-----------------------------------------------------------------------
// adjustInto()
//-----------------------------------------------------------------------
@Test
public void test_adjustDate() {
LocalDate base = LocalDate.of(2007, 2, 12);
for (int i = -4; i <= 2104; i++) {
Temporal result = Year.of(i).adjustInto(base);
assertEquals(result, LocalDate.of(i, 2, 12));
}
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKYear method test_with_TemporalAdjuster.
//-----------------------------------------------------------------------
// with(TemporalAdjuster)
//-----------------------------------------------------------------------
@Test
public void test_with_TemporalAdjuster() {
Year base = Year.of(-10);
for (int i = -4; i <= 2104; i++) {
Temporal result = base.with(Year.of(i));
assertEquals(result, Year.of(i));
}
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKChronoUnit method test_unitAndTemporal.
@Test(dataProvider = "unitAndTemporal")
public void test_unitAndTemporal(ChronoUnit unit, Temporal base, boolean isSupportedBy, long amount, Temporal target) {
assertEquals(unit.isSupportedBy(base), isSupportedBy);
if (isSupportedBy) {
Temporal result = unit.addTo(base, amount);
assertEquals(result, target);
assertEquals(unit.between(base, result), amount);
}
}
Aggregations