use of org.apache.phoenix.expression.function.CeilDateExpression in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testCeilDateExpressionWithMultiplier.
@Test
public void testCeilDateExpressionWithMultiplier() throws Exception {
Expression dateLiteral = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDate.INSTANCE);
Expression ceilDateExpression = CeilDateExpression.create(dateLiteral, TimeUnit.SECOND, 10);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
ceilDateExpression.evaluate(null, ptr);
Object result = ceilDateExpression.getDataType().toObject(ptr);
assertTrue(result instanceof Date);
Date resultDate = (Date) result;
assertEquals(DateUtil.parseDate("2012-01-01 14:25:30"), resultDate);
}
use of org.apache.phoenix.expression.function.CeilDateExpression in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testCeilDateExpression.
@Test
public void testCeilDateExpression() throws Exception {
LiteralExpression dateLiteral = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDate.INSTANCE);
Expression ceilDateExpression = CeilDateExpression.create(dateLiteral, TimeUnit.DAY);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
ceilDateExpression.evaluate(null, ptr);
Object result = ceilDateExpression.getDataType().toObject(ptr);
assertTrue(result instanceof Date);
Date resultDate = (Date) result;
assertEquals(DateUtil.parseDate("2012-01-02 00:00:00"), resultDate);
}
Aggregations