TimeZone.getDefault () on linux differs from user to user

I have a Linux module with two configured users. I also have this piece of Java code:

long time = System.currentTimeMillis();
String millis = Long.toString(time);
Date date = new Date(time);
System.out.println("Current time in milliseconds = " + millis + " => " + date.toString());
TimeZone tz = TimeZone.getDefault();
System.out.println("Current time zone: " + TimeZone.getDefault().getID());

If I run datein bash, I have the same result for both users:

User 1:

$ date
Fri Mar 22 10:02:58 PYST 2013

User 2:

$ date
Fri Mar 22 10:03:22 PYST 2013

However, if I run the same java code, I have:

User 1:

$ java TimeTest
Current time in milliseconds = 1363957432669 => Fri Mar 22 10:03:52 PYST 2013
Current time zone: America/Asuncion

User 2:

$ java TimeTest
Current time in milliseconds = 1363957456954 => Fri Mar 22 13:04:16 GMT 2013
Current time zone: GMT

So, I think this has something to do with how java is configured for each user.

I checked for an environment variable TZ, but there is no TZ defined for any user.

Any ideas on why I am getting different values TimeZone.getDefault()for different users in the same Linux field?

JVM:

$ java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

Distro:

$ cat /etc/issue
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
+5
source share
2
+1

/ :

  • Linux UTC
  • JVM (ex CET)
  • UTC

:

  • : /etc/localtime -> /usr/share/zoneinfo/Europe/Paris
  • /usr/share/zoneinfo/Europe/Paris UTC

cp /usr/share/zoneinfo/UTC /etc/localtime /usr/share/zoneinfo/Europe/Paris /etc/localtime, !

0

All Articles