use of java.time.Period in project spring-boot by spring-projects.
the class PeriodStyleTests method printSimpleWhenZeroWithoutUnitShouldPrintInDays.
@Test
void printSimpleWhenZeroWithoutUnitShouldPrintInDays() {
Period period = Period.ofMonths(0);
assertThat(PeriodStyle.SIMPLE.print(period)).isEqualTo("0d");
}
use of java.time.Period in project spring-boot by spring-projects.
the class NumberToPeriodConverterTests method convert.
@SuppressWarnings({ "rawtypes", "unchecked" })
private Period convert(ConversionService conversionService, Integer source, ChronoUnit defaultUnit) {
TypeDescriptor targetType = mock(TypeDescriptor.class);
if (defaultUnit != null) {
PeriodUnit unitAnnotation = AnnotationUtils.synthesizeAnnotation(Collections.singletonMap("value", defaultUnit), PeriodUnit.class, null);
given(targetType.getAnnotation(PeriodUnit.class)).willReturn(unitAnnotation);
}
given(targetType.getType()).willReturn((Class) Period.class);
return (Period) conversionService.convert(source, TypeDescriptor.forObject(source), targetType);
}
use of java.time.Period in project j2objc by google.
the class TCKPeriod method test_multipliedBy_overflowTooBig.
@Test(expected = ArithmeticException.class)
public void test_multipliedBy_overflowTooBig() {
Period test = Period.ofYears(Integer.MAX_VALUE / 2 + 1);
test.multipliedBy(2);
}
use of java.time.Period in project j2objc by google.
the class TCKPeriod method factory_parse_plus.
@Test()
@UseDataProvider("data_factory_parseSuccess")
public void factory_parse_plus(String text, Period expected) {
Period p = Period.parse("+" + text);
assertEquals(p, expected);
}
use of java.time.Period in project j2objc by google.
the class TCKPeriod method test_multipliedBy.
// -----------------------------------------------------------------------
// multipliedBy()
// -----------------------------------------------------------------------
@Test
public void test_multipliedBy() {
Period test = Period.of(1, 2, 3);
assertPeriod(test.multipliedBy(0), 0, 0, 0);
assertPeriod(test.multipliedBy(1), 1, 2, 3);
assertPeriod(test.multipliedBy(2), 2, 4, 6);
assertPeriod(test.multipliedBy(-3), -3, -6, -9);
}
Aggregations