让我们说我有以下问题:
SELECT to_char(request_date,'YYYY-MM-DD HH24:MI:SS') date_time
FROM tableA;
输出类似于:
date_time
-------------------------
2015-12-19 11:27:57
现在,我想选择时间戳为00:00:00,无论它实际是什么时间戳。我怎样才能做到这一点?我的意思是我想得到如下结果:
date_time
-------------------------
2015-12-19 00:00:00
请指教。谢谢!
答案 0 :(得分:4)
最简单的方法是截断日期:
Calendar today = Calendar.getInstance();
today.set(HOUR_OF_DAY, 0);
today.set(MINUTE, 0);
today.set(SECOND, 0);
today.set(MILLISECOND, 0);
Calendar date = Calendar.getInstance();
date.setTime(formatter.parse(LastUpdate));
date.set(HOUR_OF_DAY, 0);
date.set(MINUTE, 0);
date.set(SECOND, 0);
date.set(MILLISECOND, 0);
today.compareTo(date)