Joda时区计算

Mik*_*e Q 7 java timezone jodatime

一直在玩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() );
Run Code Online (Sandbox Code Playgroud)

并得到以下输出

2011-10-24T13:00:12.890Z
2011-10-24T12:00:12.937-01:00
2011-10-24T14:00:12.937+01:00
Run Code Online (Sandbox Code Playgroud)

看到"gmtPlusOne"以-01:00落后一小时,而"gmtMinusOne"则相反,我感到有些惊讶.有人可以解释为什么这些会像我预期的那样出现.

Nar*_*ala 15

文档解释了这种不那么直观的行为的原因.它表示Etc/GMT+1标准偏移量为-1:00,Etc/GMT-1标准偏移量为+1:00.这种抵消的逆转适用于任何Etc/GMT+n.

来自维基

Etc的特殊区域用于某些管理区域,特别是代表协调世界时的"Etc/UTC".为了符合POSIX风格,那些以"Etc/GMT"开头的区域名称与大多数人的期望相反.在这种风格中,格林威治标准时间以西的区域有一个正号,而东方的区域有一个负号(例如"Etc/GMT-14"比格林威治标准时间早14个小时/东部.)