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