乔达 时区计算
一直在研究 Joda 时区,发现以下内容似乎很奇怪。
我运行了以下代码
DateTimeZone gmt = DateTimeZone.forID( "Etc/GMT" );
DateTimeZone gmtPlusOne = DateTimeZone.forID( "Etc/GMT+1" );
DateTimeZone gmtMinusOne = DateTimeZone.forID( "Etc/GMT-1" );
System.out.println( new DateTime( gmt ).toString() );
System.out.println( new DateTime( gmtPlusOne ).toString() );
System.out.println( new DateTime( gmtMinusOne ).toString() );
并得到了以下输出,
2011-10-24T13:00:12.890Z
2011-10-24T12:00:12.937-01:00
2011-10-24T14:00:12.937+01:00
我有点惊讶地看到“gmtPlusOne”以 -01:00 落后一小时而“gmtMinusOne”则相反。有人能解释一下为什么这些结果会像我预期的相反吗?
Been playing around with Joda timezones and found the following which seemed odd.
I ran the following code
DateTimeZone gmt = DateTimeZone.forID( "Etc/GMT" );
DateTimeZone gmtPlusOne = DateTimeZone.forID( "Etc/GMT+1" );
DateTimeZone gmtMinusOne = DateTimeZone.forID( "Etc/GMT-1" );
System.out.println( new DateTime( gmt ).toString() );
System.out.println( new DateTime( gmtPlusOne ).toString() );
System.out.println( new DateTime( gmtMinusOne ).toString() );
And got the following output
2011-10-24T13:00:12.890Z
2011-10-24T12:00:12.937-01:00
2011-10-24T14:00:12.937+01:00
I was a bit suprised to see "gmtPlusOne" coming out as one hour behind with -01:00 and the reverse for "gmtMinusOne". Can someone explain why these come out like this as I would have expected the opposite.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个文档解释了这种不那么直观的行为的原因。它表示
Etc/GMT+1
的标准偏移量为-1:00
,而Etc/GMT-1
的标准偏移量为>+1:00
。这种偏移量的逆转适用于任何Etc/GMT+n
。来自 wiki
This documentation explains the reason for this not so intuitive behavior. It says
Etc/GMT+1
has a standard offset of-1:00
andEtc/GMT-1
has a standard offset of+1:00
. This reversal of offset holds for anyEtc/GMT+n
.From wiki