gpt4 book ai didi

java - TimeZone.getDefault() 方法的输出

转载 作者:行者123 更新时间:2023-11-29 05:43:00 26 4
gpt4 key购买 nike

当我运行以下行时,

    System.out.println(java.util.TimeZone.getDefault());

我得到了以下输出。

  sun.util.calendar.ZoneInfo[id="Asia/Calcutta",
offset=19800000,
dstSavings=0,
useDaylight=false,
transitions=6,
lastRule=null]

System.out.println(Locale.getDefault()); 给出

`en_US` 

我的疑问是

Locale 怎么会是 en_US,而我的 Zone idAsia/Calcutta

在第一个输出中,我还没有理解什么是 offset、dstSavings、useDaylight、transitions 和 rules?

任何人都可以帮助理解这些。

提前致谢...

最佳答案

LocaleTimeZone 无关,如果您愿意,您可以在澳大利亚将您的计算机设置为法语...您不需要法国时区。

要了解有关 TimeZone 的更多信息,您应该阅读以下文章:

使用夏令时

public abstract boolean useDaylightTime()

Queries if this time zone uses daylight savings time.

什么是 Daylight Saving Time .

getDSTSavings

public int getDSTSavings()

Returns the amount of time to be added to local standard time to get local wall clock time.

这就是 UTC + TimeZone + (DSTSavings - 0 或 1 小时) 之间的差异。如果您当前处于 DST 节省模式,将返回 1 小时。

规则

规则表示 DST 激活的日期和它不再存在的日期。更多信息 SimpleTimeZone .

过渡

This array describes transitions of GMT offsets of this time zone, including both raw offset changes and daylight saving time changes. A long integer consists of four bit fields.

The most significant 52-bit field represents transition time in milliseconds from Gregorian January 1 1970, 00:00:00 GMT. The next 4-bit field is reserved and must be 0. The next 4-bit field is an index value to offsets[] for the amount of daylight saving at the transition. If this value is zero, it means that no daylight saving, not the index value zero. The least significant 4-bit field is an index value to offsets[] for total GMT offset at the transition.

If this time zone doesn't observe daylight saving time and has never changed any GMT offsets in the past, this value is null.

关于java - TimeZone.getDefault() 方法的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16850064/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com