I have a problem with java timezones if anyone can help me.
I have a web application running on tomcat 5.5 (not sure if this is relevant) with the next version of JVM
[someuser@webserver bin]$ java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode) [someuser@webserver bin]$
System date, say -
[someuser@webserver bin]$ date Mon Aug 15 09:09:46 EST 2011
In a web application, I make a call at a specific point in Calendar.getInstance().getTime() and I print this timestamp in the logs.
The problem is that this timestamp is returned in EDT, although the server time is in EST. For this reason, the date is returned 1 hour later than it should.
I want to reach Calendar.getInstance().getTime() to return the date in the same time zone as the system.
I searched the forums and found some suggestions that jvm does not read the system time zone correctly. I tried to start tomcat with the -Duser.timezone=EST parameter, but the system saves the returned timestamps in the EDT time zone. Note: trying -Duser.timezone with the non-est option works. The problems seem to be different.
My problem is somehow similar to this SO question . However, I am only trying to get the date in the same time zone as the system, without any special processing.
Can you help?
java timezone
Andrei
source share