gpt4 book ai didi

java - 如何获取 GMT 时间,如 2016-02-28/20 :31 GMT

转载 作者:行者123 更新时间:2023-12-02 04:04:33 28 4
gpt4 key购买 nike

我也想要 GMT 字符串的时间。

但我无法得到它。

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd/hh-mm");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = new Date();
System.out.println("date "+dateFormat.format(date));

但是我变成这样了2015-12-28/11-53末尾没有 GMT

最佳答案

使用

 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd/hh-mm z");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));

而不是

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd/hh-mm");

其中'z'表示时区

关于java - 如何获取 GMT 时间,如 2016-02-28/20 :31 GMT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34493153/

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