我在 Java 中创建了一个 Date
对象.当我这样做时,它会显示如下内容:date=Tue Aug 09 00:00:00 IST 2011
.结果,我的 Excel 文件似乎小了一天(2 月 27 日变成了 2 月 26 日,依此类推)我认为这一定是因为时间.如何将其设置为下午 5:30?
I created a Date
object in Java. When I do so, it shows something like: date=Tue Aug 09 00:00:00 IST 2011
. As a result, it appears that my Excel file is lesser by one day (27 feb becomes 26 feb and so on) I think it must be because of time. How can I set it to something like 5:30 pm?
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY,17);
cal.set(Calendar.MINUTE,30);
cal.set(Calendar.SECOND,0);
cal.set(Calendar.MILLISECOND,0);
Date d = cal.getTime();
另见
这篇关于如何在java中将时间设置为日期对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!