gpt4 book ai didi

java - 将 apache.axis.types.Duration 转换为 HH :mm format

转载 作者:行者123 更新时间:2023-12-01 05:14:19 25 4
gpt4 key购买 nike

请引用以下主要方法:

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()));
}

当我运行此命令时,我得到的输出是 05:30,预期输出是 17:30。即使我尝试使用“HH:mm”格式但没有得到预期的输出。它转换为 12 小时格式而不是 24 小时格式。

请帮忙。

最佳答案

为什么你不能简单地使用

System.out.println(dur.getHours()+":"+dur.getMinutes());

关于java - 将 apache.axis.types.Duration 转换为 HH :mm format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11522664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com