Ramblings of a Sun employee
Coffey's Blog
Archives
« November 2009
MonTueWedThuFriSatSun
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
      
Today
Click me to subscribe
Search

Links
 

Today's Page Hits: 2

« WRC Rally - Ireland | Main | Argentina changes... »
Friday Nov 23, 2007
Want the latest timezone data support in your JRE ? - NOW ? Step right up.

As timezone support in the JRE seems to have become a more sensitive topic in recent years - more and more people want to have the latest timezone data incorporated into their environment in real time. Sun released the tzupdater tool to address such issues. Unfortunately with some timezones changes being taken at very short notice, even this effort is not enough for some java users.


Here's a quick guide (as promised) on how you can incorporate the latest timezone changes into your JRE :

  • Go, grab a copy of the latest JDK 7 code. In there you'll find all the tools necessary to build the necessary zi files.
  • Sun uses the Olson timezone data releases as its guide for timezone rules. Their release versions are in the format of tzdata<year><letter>. The current tzdata rules at time of writing are the tzdata2007i rules. Go grab a copy of these at ftp://elsie.nci.nih.gov/pub/tzdata2007i.tar.gz and extract locally.
  • Java uses the javazic tool to compile its timezone rules. Unix OSes use the zic (Zone Information Compiler) tool. You need to get a copy of the javazic tool compiled in your workspace before the new zi files can be created...

    For those of you new to compiling a JDK 7 workspace - here's what you need (paper and scissors are optional)

  • A JDK 7 binary - Set your ALT_JDK_IMPORT_PATH variable to here.
  • A JDK 6 binary - Set your ALT_BOOTDIR variable to here.
  • A Binary Plugs directory - Set your ALT_BINARY_PLUGS_PATH variable to this. - Download from http://download.java.net/openjdk/jdk7/ - Install it using something like : java -jar jdk-7-ea-plug-b23-solaris-sparc-30_oct_2007.jar
  • cd to the jdk/make directory and issue a gnumake sanity command.
  • Be sure and read the README-builds.html file included in the JDK7 source if you've issues with building. Bear in mind that http://sunfreeware.com/ is a good spot to pick up any binaries that may be missing from your system.
  • Build the JDK sub directory : gnumake all
  • Once you have a build - you're good to make changes to the tzdata files.

    
    fireball $pwd 
    /space/sean/JDK7/openjdk/jdk/make/sun/javazic/tzdata
    fireball $cp -r ~/tzdata2007i/* .
    

    Don't forget to change the tzdata version number :

     
    fireball $tail -1 VERSION 
    tzdata2007i
    

    All set for a compilation of these new tzdata files next :

    fireball $pwd 
    /space/sean/JDK7/openjdk/jdk/make/sun/javazic/tzdata
    fireball $gnumake clean
    rm -f  ../../../build/solaris-sparc/tmp/sun/sun.javazic/strip_prop_options
    rm -f  ../../../build/solaris-sparc/tmp/sun/sun.javazic/compile_prop_options
    rm -f ../../../build/solaris-sparc/tmp/sun/sun.javazic/.classes.list
    rm -f -r ../../../build/solaris-sparc/tmp/sun/sun.javazic/obj
    rm -f -r ../../../build/solaris-sparc/tmp/sun/sun.javazic/obj_*
    rm -f -r ../../../build/solaris-sparc/classes/sun/javazic
    rm -f ../../../build/solaris-sparc/tmp/sun/sun.javazic/.classes.list
    rm -f -r ../../../build/solaris-sparc/tmp/sun/sun.javazic ../../../build/solaris-sparc/lib/zi 
    fireball $gnumake all rm -f -r ../../../build/solaris-sparc/tmp/sun/sun.javazic/zi /usr/bin/mkdir -p ../../../build/solaris-sparc/tmp/sun/sun.javazic/zi rm -f ../../../build/solaris-sparc/tmp/sun/sun.javazic/zi/ZoneInfoMappings /space/sean/jdk/jdk1.6.0_03//bin/java -client -Xmx896m -Xms128m -XX:PermSize=32m
    -XX:MaxPermSize=160m -jar ../../../build/solaris-sparc/btjars/javazic.jar -V "`/usr/bin/grep '^tzdata'
    ./tzdata/VERSION`" -d../../../build/solaris-sparc/tmp/sun/sun.javazic/zi ./tzdata/africa ./tzdata/antarctica
    ./tzdata/asia ./tzdata/australasia ./tzdata/europe ./tzdata/northamerica ./tzdata/pacificnew
    ./tzdata/southamerica ./tzdata/backward ./tzdata/etcetera ./tzdata/solar87
    ./tzdata/solar88 ./tzdata/solar89 ./tzdata/systemv ./tzdata_jdk/gmt ./tzdata_jdk/jdk11_backward rm -f -r ../../../build/solaris-sparc/lib/zi /usr/bin/mkdir -p ../../../build/solaris-sparc/lib/zi rm -f ../../../build/solaris-sparc/lib/zi/ZoneInfoMappings /usr/bin/cp -r ../../../build/solaris-sparc/tmp/sun/sun.javazic/zi/* ../../../build/solaris-sparc/lib/zi
    Et VoilĂ ! - a new directory full of the latest timezone rules ready for deployment. The new files will work with JDK 7 or earlier JRE releases. - Just replace the jre/lib/zi directory with the newly created one from your workspace. You should ensure that any instance of the JRE being updated is shut down first - otherwise the risk of the JRE continuing to hold references to older timezone data exists.
    Posted at 05:15PM Nov 23, 2007 by coffeys in Sun  |  Comments[2]

    Comments:

    Thanks for the excellent information on changing the DST in JRE.
    We are trying to simulate the DST in our test environment.
    As part of this process, we want to modify the rules so that the short day and long day can be any day we choose.

    Currently, we chose lastSun of Feb as short day and lastSun of March as long day.
    Can you please provide us an example as to what needs to be changed in the "northamerica" file?

    We have changed the following in "northamerica" file:
    ----------------------------
    # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
    Rule US 2007 max - Feb lastSun 2:00 0:00 D
    Rule US 2007 max - Mar lastSun 2:00 0 S
    ---------------------------------------

    Is there any other place we need to change in "northamerica" file?
    This northamerica file is from the tzdata version "tzdata2007k"

    The problem with this change is that one hour is being added to every hour subsequent to last Sunday in Feb until the actual Short day (March 9).
    After March 9, one hour is substracted from wall time from every hour until the actual Long Day (Nov 2).

    Are there any known bugs/fixes to "javazic" code?

    Your help will be very much appreciated.

    Best Regards,
    Praveen

    Posted by Praveen Patle on January 18, 2008 at 12:36 AM GMT #

    Hi Praveen,

    You should be able to implement any rules that you want. The javazic tool is pretty robust with reading zic rules.

    You have an error in the changes that you made. For you daylight savings you've specified 0:00 as the number of hours to save. This will have no effect.

    the following should work.

    # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
    Rule US 2007 max - Feb lastSun 2:00 1:00 D
    Rule US 2007 max - Mar lastSun 2:00 0 S

    Sean.

    Posted by coffeys on January 28, 2008 at 03:14 PM GMT #

    Post a Comment:
    • HTML Syntax: NOT allowed