小编use*_*039的帖子

Simple HateFormat上java HH:mm和hh:mm之间的差异

什么是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));
Run Code Online (Sandbox Code Playgroud)

打印:

24:00:00
00:00:00
05:30:00
Run Code Online (Sandbox Code Playgroud)

java format date

50
推荐指数
5
解决办法
10万
查看次数

标签 统计

date ×1

format ×1

java ×1