Sunday, 5 August 2007

Java Timezone Wrong on Fedora

How's this for annoying:
bash$ groovy -e "println new java.util.Date()"
Mon Aug 06 01:40:33 EDT 2007

bash$ date
Mon Aug  6 00:40:35 CDT 2007

bash$ /usr/sbin/zdump /etc/localtime
/etc/localtime  Mon Aug  6 00:41:45 2007 CDT

bash$ cat /etc/timezone
America/Chicago
This is on Fedora. Java seems to have decided I'm on the east coast, and stubbornly refuses to look at any of the many sources where it could determine that I'm in the central timezone.

To save you some trouble, here's the solution:

bash$ export TZ="US/Central"
bash$ groovy -e "println new java.util.Date()"
Mon Aug 06 00:49:02 CDT 2007
To make this automatic, I added the export TZ line to /etc/profile.d/java.sh , which is where I set my JAVA_HOME, ANT_HOME, GROOVY_HOME and so on.

Technorati Tags:

Posted by spout at 7:48 PM in stuff about java
« August »
SunMonTueWedThuFriSat
   1234
567891011
12131415161718
19202122232425
262728293031