提交 b630de4a authored 作者: Patrick Brielmayer's avatar Patrick Brielmayer

Added nano seconds to the resulting date

上级 497be6ac
......@@ -912,7 +912,10 @@ public class DateTimeUtils {
Calendar calendar = Calendar.getInstance();
calendar.setTime(refDate);
calendar.add(Calendar.MONTH, nrOfMonthsToAdd);
return new Timestamp(calendar.getTime().getTime());
Timestamp resultDate = new Timestamp(calendar.getTimeInMillis());
resultDate.setNanos(refDate.getNanos());
return resultDate;
}
}
......@@ -1415,6 +1415,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
date = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-08-21").getTime());
expected = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2003-05-21").getTime());
assertEquals(expected, DateTimeUtils.addMonths(new Timestamp(date.getTime()), -3));
// 21-Aug-2003 00:00:00:333 - 3 months = 21-May-2003 00:00:00:333
date = new Timestamp(new SimpleDateFormat("yyyy-MM-dd SSS").parse("2003-08-21 333").getTime());
expected = new Timestamp(new SimpleDateFormat("yyyy-MM-dd SSS").parse("2003-05-21 333").getTime());
assertEquals(expected, DateTimeUtils.addMonths(new Timestamp(date.getTime()), -3));
}
private void testToCharFromDateTime() throws SQLException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论