use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_from_TemporalAmount_Duration.
//-----------------------------------------------------------------------
// from(TemporalAmount)
//-----------------------------------------------------------------------
@Test
public void factory_from_TemporalAmount_Duration() {
TemporalAmount amount = Duration.ofHours(3);
assertEquals(Duration.from(amount), Duration.ofHours(3));
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_from_TemporalAmount_Minutes_tooBig.
@Test(expectedExceptions = ArithmeticException.class)
public void factory_from_TemporalAmount_Minutes_tooBig() {
TemporalAmount amount = new TemporalAmount() {
@Override
public long get(TemporalUnit unit) {
return (Long.MAX_VALUE / 60) + 2;
}
@Override
public List<TemporalUnit> getUnits() {
return Collections.<TemporalUnit>singletonList(MINUTES);
}
@Override
public Temporal addTo(Temporal temporal) {
throw new UnsupportedOperationException();
}
@Override
public Temporal subtractFrom(Temporal temporal) {
throw new UnsupportedOperationException();
}
};
Duration.from(amount);
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_plus_TemporalAmount_wrap.
@Test
public void test_plus_TemporalAmount_wrap() {
TemporalAmount p = MockSimplePeriod.of(1, HOURS);
LocalTime t = LocalTime.of(23, 30).plus(p);
assertEquals(t, LocalTime.of(0, 30));
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_plus_TemporalAmount_dateNotAllowed.
@Test(expectedExceptions = DateTimeException.class)
public void test_plus_TemporalAmount_dateNotAllowed() {
TemporalAmount period = MockSimplePeriod.of(7, ChronoUnit.MONTHS);
TEST_12_30_40_987654321.plus(period);
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_minus_TemporalAmount_negativeMinutes.
@Test
public void test_minus_TemporalAmount_negativeMinutes() {
TemporalAmount period = MockSimplePeriod.of(-25, ChronoUnit.MINUTES);
LocalTime t = TEST_12_30_40_987654321.minus(period);
assertEquals(t, LocalTime.of(12, 55, 40, 987654321));
}
Aggregations