java - 时区的奇怪行为

标签 java timezone

我运行以下 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/

相关文章:

javascript - 检查现有日期对象是否为 UTC - Javascript

node.js - 时刻和时区转换本地时间失败

java - 在 Java 中使用 Calendar 对象设置和格式化时区,然后返回一个 Date 对象

java - 使用 Mockito 时是否可以为所有答案添加拦截器?

java - 处理 Spring Integration 中的 Soap 错误

java - 打印从文件填充的 ArrayList 时出现 NoSuchElementException

javascript - 如何在没有 Fleegix.js 的情况下使用 timezone-js 加载时区文件?

java - 如果定义了时区,则 Calendar.getTime() 不返回 UTC 日期

加载JNI共享库失败(JDK)

java - 具有 Keep-Alive 能力的 HTTP 服务器