On Linux/Unix: add the "-Duser.timezone=Europe/Budapest" parameter (replacing the "Europe/Budapest" part with the ID of your timezone) to the JAVA_OPTS environment variable in your {TOMCAT_HOME}/bin/startup.sh. If you don't have a line in your startup.sh for setting the JAVA_OPTS, then you can add this to the start of the file (after the shell-specification in the first line of the shell-script, of course
):
export JAVA_OPTS="-Duser.timezone=Europe/Budapest"
On Windows: start the "Configure Tomcat" program from the Start Menu, select the Java tab and add the "-Duser.timezone=Europe/Budapest" to the Java options list.
On both platforms you'll have to restart Tomcat for the new default timezone setting to take effect.
Comments
GREAT TIP !!!!
you save my life
Tomcat default timezone on Debian/Ubuntu
/etc/defaults
. For Tomcat it's the file/etc/defaults/tomcat5.5
and values of theJAVA_OPTS
variable can be specified by editingCATALINA_OPTS
in this file.The default CATALINA_OPTS might look like this:
CATALINA_OPTS="-Djava.awt.headless=true -Xmx128M -server"
And adding a default timezone might look like this:
CATALINA_OPTS="-Djava.awt.headless=true -Xmx128M -server -Duser.timezone=Europe/Budapest"
This worked for me
Setting timezone to local time
I have setup the time zone and my JVM (in which tomcat runs) works under the same timezone. But I want it to run the JVM on my local time. If I remove the -Duser.timezone option it defaults to the UTC timings.
Do anybody have experience on how to set the time to run on local time?
Appreciate your response.
Thanks,
PG
Re: Setting timezone to local time
TimeZone.getDefault()
) of your JVM is the same as the one specified for the OS? What do you mean, when you say "I want it to run the JVM on my local time"? How would you tell whether your JVM "runs on your local time" or not? Either I do not get something here or your concept of how the JVM works with timezones, dates, calendars (etc.) is incorrect.use the following command:
Thank you
fixed the same probelm on my system too...
Thanks for the tip
Thanks!
Tomcat and flex/java web app
I've read this article and I think to have find the solution but...
I've started Tomcat 7.0 with my web app but the date is wrong! I've started my webapp with Spring server and the date is correct! I've put -Duser.timezone=Europe/Rome (as written in this article) but there's no behaviour difference. Have you some advice for me?!?!
Thanks in advance
Giuseppe
Re: Tomcat and flex/java web app
user.timezone with tomcat7
I have the same concern with an application under Tomcat7/GWT
Re: user.timezone with tomcat7
Default timezone setting not take effort.
The below timezone setting not take effort even after twice restart the tomcat service.
Start the "Configure Tomcat" program from the Start Menu, select the Java tab and add the "-Duser.timezone=Asia/Singapore" to the Java options list.
Re: Default timezone setting not take effort
Timezone setting
JAVA_OPTS=-Duser.timezone=CST6CDT
export JAVA_OPTS
Then I stopped and restarted the Tomcat.
The variable took effect and my issue is resolved.