Getting the correct time in JVM 1.5 and 1.6

Maybe some of you out there are also using Sun’s JVM on your linux box but did not yet realise that the timezone settings in Java would not match the ones you use in you Gnome settings or system settings. The reason for that is that the JVM looks at a file /etc/localtime to find these timezone settings and apparently wants it to be a Symlink and not a file per se, so let’s fix it~

  1. backup your /etc/localtime
    sudo cp /etc/localtime /etc/localtime.bak
  2. now let’s link to the correct file after making a backup of it. In my case “Asia/Hong_Kong”, look for other regions in /usr/share/zoneinfo/
    sudo cp /usr/share/zoneinfo/Asia/Hong_Kong /usr/share/zoneinfo/Asia/Hong_Kong.bak
    sudo ln -s -f /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>