Questions tagged «java.util.calendar»

12
将时间设置为00:00:00
我在用Java重置小时数时遇到问题。对于给定的日期,我要将小时设置为00:00:00。 这是我的代码: /** * Resets milliseconds, seconds, minutes and hours from the provided date * * @param date * @return */ public static Date trim(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR, 0); return calendar.getTime(); } 问题是,时间有时是这样12:00:00,有时是这样00:00:00,当我查询数据库中保存的实体以及查询07.02.2013 00:00:00的实际实体时间即存储12:00:00失败时。 我知道12:00:00 == 00:00:00! 我正在使用AppEngine。这是Appengine错误,问题还是其他问题?还是取决于其他因素?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.