[英]Strange behaviour while initializing time with JODA's DateTime() constructor on Android
I faced strange behaviour of JODA's time constructor. 我遇到了JODA的时间构造函数的奇怪行为。
So I execute following lines 所以我执行以下行
DateTime d1 = new DateTime("1972-01-01T10:00:00.000+00:00");
DateTime d2 = new DateTime("1970-01-01T10:00:00.000+00:00");
String s1 = d1.toString();
String s2 = d2.toString();
and see that 看到了
s1 = 1972-01-01T10:00:00.000Z
s2 = 1970-01-01T11:00:00.000+01:00
Ok, I know about default time zone for DateTime, but why different calls returns time objects with different timezones? 好的,我知道DateTime的默认时区,但是为什么不同的调用会返回具有不同时区的时间对象?
If you try to change the first year 1972->1971, you see another picture 如果你试图改变1972年至1971年的第一年,你会看到另一张照片
s1 = 1971-01-01T11:00:00.000+01:00
s2 = 1970-01-01T11:00:00.000+01:00
My current time zone is +1 (Europe/Berlin). 我目前的时区是+1(欧洲/柏林)。
What have I missed? 我错过了什么?
I can't reproduce this for Europe/Berlin
timezone, but that's the result I get with Europe/London
, for all three years. 我无法在
Europe/Berlin
时区重现这一点,但这是我三年来在Europe/London
获得的结果。
And iirc the reason is that in the early 70s the UK was in a period where we stayed on +1 all winter. 而且iirc的原因在于,在70年代初期,英国处于整个冬季都保持+1的时期。 So the epoch time expressed in Europe/London is actually
1970-01-01T01:00:00+01:00
. 因此,在欧洲/伦敦表达的纪元时间实际上是
1970-01-01T01:00:00+01:00
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.