kk:mm,HH:mm和hh:mm格式有何区别?
SimpleDateFormat broken = new SimpleDateFormat("kk:mm:ss");
broken.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
SimpleDateFormat working = new SimpleDateFormat("HH:mm:ss");
working.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
SimpleDateFormat working2 = new SimpleDateFormat("hh:mm:ss");
working.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
System.out.println(broken.format(epoch));
System.out.println(working.format(epoch));
System.out.println(working2.format(epoch));
打印品:
24:00:00
00:00:00
05:30:00
最佳答案
kk:(01-24)看起来像01,02..24。
HH:(00-23)看起来像00,01..23。
hh:(AM/PM中的01-12)看起来像01,02..12。
所以最后的打印输出(working2
)有点奇怪。应该说12:00:00
(编辑:如果您设置的是working2
时区和格式,则不是(如kdagli所指出的))