Date stored in database one day earlier


I am getting this weird issue, where I mark a given day, and the day stored in the db is one day before. So if I mark 1st November, I get 31st October in the db.

Have removed the serverTimeZone connection string attribute and no luck.

Have googled around and seems that the mysql server might be doing adjustments when storing, but finding no easy solution.

Has anybody dealt with this problem before_


Carlos Conti.

Try to debug SQL queries and see what exactly data is being passed to the MySQL. Logging setup is described in the documentation. If the application sends the correct data, then the problem with your DB settings, refer to the documentation for your DB version.

Hi, your Tomcat timezone and MySQL timezone are different. Even if you remove the serverTimeZone parameter, MySQL still runs under the UTC TZ.

You must setup your JVM to run on UTC as well, otherwise you need to setup MySQL with TZ data manually (see:

The easiest solution is the former. While developing set UTC TZ for tomcat in the file deploy/tomcat/bin/

CATALINA_OPTS="-Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -Dapp.home=\"$CATALINA_BASE/../app_home\""

# Uncomment in case of slow startup on Linux VM

#-Djava.rmi.server.hostname=localhost \ \ \"



Remember to re-apply this change every time you re-deploy tomcat (thus deleting the deploy dir).