aspose file tools*
The moose likes Java in General and the fly likes Do the JVM's Calendar/Date objects use the system's tzdata for daylight savings time changes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Do the JVM Watch "Do the JVM New topic
Author

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

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4657
    
    5

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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 ?


[My Blog]
All roads lead to JavaRanch
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4657
    
    5

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

You can use the tzUpdater Tool to update the timezone settings.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14149
    
  18

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do the JVM's Calendar/Date objects use the system's tzdata for daylight savings time changes?