This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • 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?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the tzUpdater Tool to update the timezone settings.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic