When I run the below line,
System.out.println(java.util.TimeZone.getDefault());
I got the following output.
sun.util.calendar.ZoneInfo[id="Asia/Calcutta",
offset=19800000,
dstSavings=0,
useDaylight=false,
transitions=6,
lastRule=null]
and
System.out.println(Locale.getDefault());
gives
`en_US`
My doubt is
How could the Locale
be en_US
, When My Zone id
is Asia/Calcutta
?
in the first output, I haven't understood what are offset, dstSavings, useDaylight, transitions and rules ?
Could anybody help in understanding these.
Thanks in advance...
Locale
has nothing to do with TimeZone
, you can setup your computer in French in Australia if you want... you won't need France TimeZone for that.
To know more about TimeZone, you should read theses :
toString()
: ZoneInfouseDaylightTime
public abstract boolean useDaylightTime()
Queries if this time zone uses daylight savings time.
What is 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.
So this is the difference between the UTC + TimeZone + (DSTSavings - 0 or 1 hour). If you are currently in DST savings mode, will return 1 hour.
rules
Rules mean the date when the DST is active and date when it is no more. More info SimpleTimeZone.
transitions
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.