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:(上午/下午的 01-12)看起来像 01、02..12。
所以最后的打印输出 (working2
) 有点奇怪。应该说 12:00:00
(编辑:如果你设置 working2
时区和格式,(正如 kdagli 指出的那样)你不是)
关于java - java HH :mm and hh:mm on SimpleDateFormat之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17341214/