我想以毫秒为单位获取当前日期,只有年、月和日期.但是当我使用这段代码时:
I would like to get the current date in milliseconds with only year, month and date. But when I use this code:
Calendar cal = Calendar.getInstance();
cal.clear(Calendar.HOUR);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
currentDate = cal.getTimeInMillis();
我仍然以毫秒为单位获得时间.我该如何解决这个问题?
I still get the time in milliseconds with the hour. How can I fix this?
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
currentDate = cal.getTimeInMillis();
请注意日历的时区.
这篇关于Java日历获取当前日期,不带小时、分钟、秒和毫秒,以毫秒为单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!