I have a linux box with two users configured. 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 date
on 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 guess it has something to do with the way java is configured for each user.
I checked for a TZ
environment variable defined, but there is no TZ
defined for anyone of the users.
Any ideas on why am I getting different values for TimeZone.getDefault()
for different users on the same Linux box?
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)
It is probably something to do with Locale for the user.
check these variables: http://linux.die.net/man/1/locale
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With