4

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?

Community
  • 1
  • 1
  • Can you elaborate? Java time is based on the native system time. – BackSlash Aug 31 '18 at 10:32
  • A. I think you mean GMT. B. There shouldn't be any changes – XtremeBaumer Aug 31 '18 at 10:33
  • 1
    You are asking two distinct questions here. One is about how Java manages timezones in general, which I think is too broad as it is asked right now. The other is how Java and/or systems using Java will handle a political change in the EU that abolishes daylight-saving. Since no one here (as far as I know) can predict the future, I don't see how we could give you a useful answer besides speculation. – Max Vollmer Aug 31 '18 at 10:41
  • Summertime is about to be abolished, not long and we don’t have to worry no more – baao Aug 31 '18 at 10:56
  • Java has the *TimeZone* concept. That is basically all you need to know. For any further usage of that, you have to study that topic, to understand how it applies to your use case. The duplicated questions give some insight in what that means. – GhostCat Aug 31 '18 at 10:58
  • @bambam Maybe in some countries, not everywhere. – Jonathan Rosenne Aug 31 '18 at 11:00
  • 2
    Since I can't answer, see http://www.oracle.com/technetwork/java/javase/tzdata-versions-138805.html for examples of how changes are routinely handled. Note Java and IANA/Olson use the US term 'daylight savings time' = DST not 'summer time'. – dave_thompson_085 Aug 31 '18 at 11:34

1 Answers1

0

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");
Sai prateek
  • 11,842
  • 9
  • 51
  • 66