use of javax.measure.quantity.Time in project uom-se by unitsofmeasurement.
the class QuantitiesTest method toTest.
@Test
public void toTest() {
Quantity<Time> minute = Quantities.getQuantity(BigDecimal.ONE, Units.YEAR);
Quantity<Time> second = minute.to(Units.SECOND);
BigDecimal value = (BigDecimal) second.getValue();
value.setScale(4, RoundingMode.HALF_EVEN);
BigDecimal expected = BigDecimal.valueOf(31556952);
Assert.assertEquals(expected.setScale(4, RoundingMode.HALF_EVEN), value.setScale(4, RoundingMode.HALF_EVEN));
}
use of javax.measure.quantity.Time in project uom-se by unitsofmeasurement.
the class TimeQuantitiesTest method ofLocalTimeTemporalAdjustTest.
@Test
public void ofLocalTimeTemporalAdjustTest() {
LocalTime a = LocalTime.MIDNIGHT;
TemporalAdjuster temporalAdjuster = (temporal) -> temporal.plus(12L, ChronoUnit.HOURS);
Quantity<Time> time = TimeQuantities.getQuantity(a, () -> temporalAdjuster);
Assert.assertEquals(Integer.valueOf(12), Integer.valueOf(time.getValue().intValue()));
Assert.assertEquals(Units.HOUR, time.getUnit());
}
use of javax.measure.quantity.Time in project uom-se by unitsofmeasurement.
the class TimeQuantitiesTest method ofTemporalTest.
@Test
public void ofTemporalTest() {
LocalDate a = Year.of(2015).atMonth(Month.JANUARY).atDay(9);
LocalDate b = Year.of(2015).atMonth(Month.JANUARY).atDay(10);
Quantity<Time> time = TimeQuantities.getQuantity(a, b);
Assert.assertEquals(Integer.valueOf(1), Integer.valueOf(time.getValue().intValue()));
Assert.assertEquals(Units.DAY, time.getUnit());
}
use of javax.measure.quantity.Time in project indriya by unitsofmeasurement.
the class TimeQuantitiesTest method ofLocalTimeTemporalAdjustTest.
@Test
public void ofLocalTimeTemporalAdjustTest() {
LocalTime a = LocalTime.MIDNIGHT;
TemporalAdjuster temporalAdjuster = (temporal) -> temporal.plus(12L, ChronoUnit.HOURS);
Quantity<Time> time = TimeQuantities.getQuantity(a, () -> temporalAdjuster);
assertEquals(Integer.valueOf(12), Integer.valueOf(time.getValue().intValue()));
assertEquals(Units.HOUR, time.getUnit());
}
use of javax.measure.quantity.Time in project indriya by unitsofmeasurement.
the class QuantitiesTest method toTest.
@Test
public void toTest() {
Quantity<Time> minute = Quantities.getQuantity(BigDecimal.ONE, Units.YEAR);
Quantity<Time> second = minute.to(Units.SECOND);
BigDecimal value = (BigDecimal) second.getValue();
value.setScale(4, RoundingMode.HALF_EVEN);
BigDecimal expected = BigDecimal.valueOf(31556952);
assertEquals(expected.setScale(4, RoundingMode.HALF_EVEN), value.setScale(4, RoundingMode.HALF_EVEN));
}
Aggregations