[英]Android.text.format.Time not setting isDst correctly?
I'm trying to set a Time object to be 15 minutes past the current time, according to following: 我试图将Time对象设置为比当前时间晚15分钟,具体如下:
Time time = new Time("EST");
time.setToNow();
time.minute += 15;
time.normalize(true);
However, after time.setToNow(), I notice in the debugger that the time object's isDST field equals 0, which indicates not in DST according to the reference. 但是,在time.setToNow()之后,我在调试器中注意到时间对象的isDST字段等于0,这表示根据引用不在DST中。 Also according to the reference, time.normalize(true) method is supposed to set the isDst field to -1, then compute the correct value for isDst, but in my case the isDst value stays the same, at 0, so the time is shifted back one hour.
同样根据引用,time.normalize(true)方法应该将isDst字段设置为-1,然后计算isDst的正确值,但在我的情况下,isDst值保持不变,为0,所以时间是转了一个小时。
I know we're in DST now, so I expect the isDst field to reflect this, but it's not. 我知道我们现在在DST,所以我希望isDst字段可以反映这一点,但事实并非如此。 Any ideas?
有任何想法吗?
I know we're in DST now, so I expect the isDst field to reflect this, but it's not.
我知道我们现在在DST,所以我希望isDst字段可以反映这一点,但事实并非如此。 Any ideas?
有任何想法吗?
It's possible that it's because you've given "EST"
as a time zone. 这可能是因为你把
"EST"
作为时区。 That's Eastern standard time - which has no concept of DST. 这是东部标准时间 - 没有DST的概念。
If you use something like "America/New_York"
instead, I suspect you'll get a different answer. 如果你使用像
"America/New_York"
这样的东西,我怀疑你会得到一个不同的答案。 That's a zoneinfo time zone identifier, which covers both EST and EDT at different points in the year. 这是一个zoneinfo时区标识符,涵盖了当年不同点的EST和EDT。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.