gpt4 book ai didi

java - 时区的奇怪行为

转载 作者:搜寻专家 更新时间:2023-10-31 19:56:17 26 4
gpt4 key购买 nike

我运行以下 Java 代码:

TimeZone tz1 = TimeZone.getTimeZone("Etc/GMT-3");
System.out.println(tz1.getDisplayName());

显示为 GMT+03:00 !

似乎当我们使用带有Etc/GMTxx等id的时区时,符号是反的。为什么 ?

最佳答案

这是 ETC 风格:

http://en.wikipedia.org/wiki/Zoneinfo

The special area of "Etc" is used for some administrative zones, particularly for "Etc/UTC" which represents Coordinated Universal Time. In order to conform with the POSIX style, those zone names beginning with "Etc/GMT" have their sign reversed from what most people expect. In this style, zones west of GMT have a positive sign and those east have a negative sign in their name (e.g "Etc/GMT-14" is 14 hours ahead/east of GMT.)

关于java - 时区的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16214066/

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