use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_minus_TemporalAmount_wrap.
@Test
public void test_minus_TemporalAmount_wrap() {
TemporalAmount p = MockSimplePeriod.of(1, HOURS);
LocalTime t = LocalTime.of(0, 30).minus(p);
assertEquals(t, LocalTime.of(23, 30));
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKPeriod method factory_from_TemporalAmount_Years_tooBig.
@Test(expectedExceptions = ArithmeticException.class)
public void factory_from_TemporalAmount_Years_tooBig() {
TemporalAmount amount = new TemporalAmount() {
@Override
public long get(TemporalUnit unit) {
return ((long) (Integer.MAX_VALUE)) + 1;
}
@Override
public List<TemporalUnit> getUnits() {
return Collections.<TemporalUnit>singletonList(YEARS);
}
@Override
public Temporal addTo(Temporal temporal) {
throw new UnsupportedOperationException();
}
@Override
public Temporal subtractFrom(Temporal temporal) {
throw new UnsupportedOperationException();
}
};
Period.from(amount);
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKPeriod method factory_from_TemporalAmount_YearsDays.
@Test
public void factory_from_TemporalAmount_YearsDays() {
TemporalAmount amount = new TemporalAmount() {
@Override
public long get(TemporalUnit unit) {
if (unit == YEARS) {
return 23;
} else {
return 45;
}
}
@Override
public List<TemporalUnit> getUnits() {
List<TemporalUnit> list = new ArrayList<>();
list.add(YEARS);
list.add(DAYS);
return list;
}
@Override
public Temporal addTo(Temporal temporal) {
throw new UnsupportedOperationException();
}
@Override
public Temporal subtractFrom(Temporal temporal) {
throw new UnsupportedOperationException();
}
};
assertPeriod(Period.from(amount), 23, 0, 45);
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKPeriod method test_plus_TemporalAmount_DaysHours.
@Test(expectedExceptions = DateTimeException.class)
public void test_plus_TemporalAmount_DaysHours() {
TemporalAmount amount = new TemporalAmount() {
@Override
public long get(TemporalUnit unit) {
if (unit == DAYS) {
return 1;
} else {
return 2;
}
}
@Override
public List<TemporalUnit> getUnits() {
List<TemporalUnit> list = new ArrayList<>();
list.add(DAYS);
list.add(HOURS);
return list;
}
@Override
public Temporal addTo(Temporal temporal) {
throw new UnsupportedOperationException();
}
@Override
public Temporal subtractFrom(Temporal temporal) {
throw new UnsupportedOperationException();
}
};
pymd(4, 5, 6).plus(amount);
}
use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.
the class TCKPeriod method factory_from_TemporalAmount_Period.
//-----------------------------------------------------------------------
// from(TemporalAmount)
//-----------------------------------------------------------------------
@Test
public void factory_from_TemporalAmount_Period() {
TemporalAmount amount = Period.of(1, 2, 3);
assertPeriod(Period.from(amount), 1, 2, 3);
}
Aggregations