use of java.time.Period in project flink by apache.
the class ExpressionConverterTest method testIntervalYearMonth.
@Test
public void testIntervalYearMonth() {
Period value = Period.of(999, 3, 1);
RexNode rex = converter.visit(valueLiteral(value));
assertThat(((RexLiteral) rex).getValueAs(BigDecimal.class), equalTo(BigDecimal.valueOf(value.toTotalMonths())));
// TODO planner ignores the precision
assertThat(rex.getType().getSqlTypeName(), equalTo(SqlTypeName.INTERVAL_YEAR_MONTH));
assertThat(rex.getType().getPrecision(), // year precision, should actually be 3
equalTo(2));
}
use of java.time.Period in project spring-boot by spring-projects.
the class PeriodStyleTests method printIso8601ShouldPrint.
@Test
void printIso8601ShouldPrint() {
Period period = Period.parse("-P-6M+3D");
assertThat(PeriodStyle.ISO8601.print(period)).isEqualTo("P6M-3D");
}
use of java.time.Period in project spring-boot by spring-projects.
the class PeriodStyleTests method printIso8601ShouldIgnoreUnit.
@Test
void printIso8601ShouldIgnoreUnit() {
Period period = Period.parse("-P3Y");
assertThat(PeriodStyle.ISO8601.print(period, ChronoUnit.DAYS)).isEqualTo("P-3Y");
}
use of java.time.Period in project spring-boot by spring-projects.
the class PeriodStyleTests method printSimpleWhenZeroWithUnitShouldPrintInUnit.
@Test
void printSimpleWhenZeroWithUnitShouldPrintInUnit() {
Period period = Period.ofYears(0);
assertThat(PeriodStyle.SIMPLE.print(period, ChronoUnit.YEARS)).isEqualTo("0y");
}
use of java.time.Period in project spring-boot by spring-projects.
the class PeriodStyleTests method printSimpleWhenNonZeroShouldIgnoreUnit.
@Test
void printSimpleWhenNonZeroShouldIgnoreUnit() {
Period period = Period.of(1, 2, 3);
assertThat(PeriodStyle.SIMPLE.print(period, ChronoUnit.YEARS)).isEqualTo("1y2m3d");
}
Aggregations