[ACCEPTED]-Java Time Zone is messed up-timezone
It's a "quirk" in the way the 7 JVM looks up the zoneinfo file. See Bug ID 6456628.
The 6 easiest workaround is to make /etc/localtime 5 a symlink to the correct zoneinfo file. For 4 Pacific time, the following commands should 3 work:
# sudo cp /etc/localtime /etc/localtime.dist
# sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
I haven't had any problems with the 2 symlink approach.
Edit: Added "sudo" to 1 the commands.
On Ubuntu, it's not enough to just change 7 the /etc/localtime file. It seems to read 6 /etc/timezone file, too. It's better follow 5 the instruction to set the time zone properly. In particular, do 4 the following:
$ sudo cp /etc/timezone /etc/timezone.dist
$ echo "Australia/Adelaide" | sudo tee /etc/timezone
Australia/Adelaide
$ sudo dpkg-reconfigure --frontend noninteractive tzdata
Current default time zone: 'Australia/Adelaide'
Local time is now: Sat May 8 21:19:24 CST 2010.
Universal Time is now: Sat May 8 11:49:24 UTC 2010.
On my Ubuntu, if /etc/localtime 3 and /etc/timezone are inconsistent, Java 2 seems to read default time zone from /etc/timezone 1 .
I had a similar issue, possibly the same 8 one. However my tomcat server runs on a 7 windows box so the symlink solution will 6 not work.
I set -Duser.timezone=Australia/Sydney
in the JAVA_OPTS
however tomcat 5 would not recognize that DST was in effect. As 4 a workaround I changed Australia/Sydney
(GMT+10:00) to Pacific/Numea
(GMT+11:00) so 3 that times would correctly display however 2 I would love to know the actual solution 1 or bug, if any.
It may help to double-check the timezone 5 rules your OS is using.
/usr/bin/zdump -v /etc/localtime | less
This file should 4 contain your daylight savings rules, like 3 this one for the year 2080:
/etc/localtime Sun Mar 31 01:00:00 2080 UTC = Sun Mar 31 02:00:00 2080 BST isdst=1 gmtoff=3600
You can compare 2 this with the timezone rules you think you 1 should be using. They can be found in /usr/share/zoneinfo/.
Adding a short answer that worked for me, you 2 can use timedatectl
to set the timezone. Then restart 1 the JVM afterwards.
sudo timedatectl set-timezone UTC
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.