1

Please refer below main method:

public static void main(String[] args) {
    Duration dur = new Duration();
    dur.setHours(17);
    dur.setMinutes(30);

    SimpleDateFormat simpDate = new SimpleDateFormat("kk:mm");
    System.out.println(simpDate.format(dur.getAsCalendar().getTime()));
}

When i run this i got output 05:30 and expected output is 17:30. Even i tried with "HH:mm" format but not getting expected output. it converts to 12 hours format rather than 24 hours format.

Please help.

4

1 回答 1

0

为什么不能简单使用

System.out.println(dur.getHours()+":"+dur.getMinutes());
于 2013-10-30T06:50:07.387 回答