• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Do the JVM's Calendar/Date objects use the system's tzdata for daylight savings time changes?

 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've recently seen some of the JDK's javadocs showing examples of daylight savings time with hard coded constants.

For example, SimpleTimeZone() says



This code is simply wrong, since Congress changed the dates when the standard/daylight changes. I've seen other examples, altho I can't find them right now.

I know that Linux systems (and I assume OS-X and Windows as well) have specific operating system-wide files to control things like time zone names, standard/daylight changes, etc. that are periodically updated. Sometimes there are updated monthly or more frequently, as lawmakers in countries all over the world love to play with things.

Seems silly to me to have a language's runtime have its own system, or worse, expect programmers to remember what the rules are.

Does the JVM use the real system definition?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is just an example of using SimpleTimeZone, but wouldn't you use TimeZone instead ? Doesn't TimeZone takes care of getting the right values for you ?
 
Pat Farrell
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote: Doesn't TimeZone takes care of getting the right values for you ?



That is my question, does the JVM do it right?

And the related question is: how often is the JVM updated to reflect silly politicians changing time. For examples:

Australia postponed its DST start in 2006 because of a sports event...
As of 2007 for example the USA will greatly expand the duration of DST (due to some Energy Conservation Act or something).
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the tzUpdater Tool to update the timezone settings.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pat Farrell wrote:That is my question, does the JVM do it right?


As far as I know, yes, it does it correctly, it gets information about daylight savings etc. from a config file that's hidden somewhere in the JRE. (I don't know which file, maybe it's somewhere inside rt.jar).

Pat Farrell wrote:And the related question is: how often is the JVM updated to reflect silly politicians changing time.


There are usually a few JDK / JRE updates a year and updated timezone / daylight savings information is almost always mentioned in the release notes. If you don't want to update your JDK or JRE you can use the timezone updater tool that Christophe mentioned.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic