I'm having an issue 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 following JVM version
[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]$
The system date is, say -
[someuser@webserver bin]$ date
Mon Aug 15 09:09:46 EST 2011
Within the web application, I make a call at a certain point to Calendar.getInstance().getTime()
, and I print this timestamp in the logs.
Problem is that this timestamp gets returned in EDT, although server's time is in EST. For this reason, the date returned is 1h later than it should.
What I want to achieve is make Calendar.getInstance().getTime()
to return a date in the same timezone as the system.
I have searched the forums, and found some suggestions that the jvm is not reading correctly the system's timezone.
I have tried starting the tomcat with -Duser.timezone=EST
parameter, but the system keeps returning timestamps in the EDT timezone. Please note - trying -Duser.timezone
with a non-est parameter seems to work.
The problems seems to be of a different nature.
My issue is somehow similar with this SO question. However, I'm only trying to get the date in the same timezone as the system is in, without any special handling.
Are you able to help?