As many of you many know, In Europe we have a summertime and a wintertime. Twice a year, the clocks in all EU Member States are switched from winter to summertime (on the last Sunday in March) and back from summer to wintertime (on the last Sunday in October) (more info here). Now, the European Commision is about to propose to get rid of those clock changes.
In Java, we have Calendars and, a calendar always knows the correct timeZone (i.e. GMT+1 for summertime and GMT+2 for wintertime). How does Java manage this? And, if it's changed, how would it affect to our systems?
So, as I see on comments, there shouldn't be any changes because Java uses System Time and it's setted by NTP, right?
Answer
I will say by java.util.TimeZone
.
TimeZone
represents a time zone offset, and also figures out daylight savings.
Typically, you get a TimeZone
using getDefault
which creates a TimeZone
based on the time zone where the program is running. For example, for a program running in Japan, getDefault
creates a TimeZone object
based on Japanese Standard Time.
You can also get a TimeZone
using getTimeZone
along with a time zone ID. For instance, the time zone ID for the U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object with:
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
No comments:
Post a Comment