Problem: The correct time on the application server is incorrect in the database.
I am in China, Timezone is UTC + 8. I use sleep mode. Define an entity as follows (language: Scala)
class CargoJournal { @Type(`type`="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime") var deliverTime: LocalDateTime = _ @Temporal(TemporalType.TIMESTAMP) @Column(nullable=false) var logDate:Date = _ }
I open the sleep log as shown on my application server. Current time on Thu Sep 13 11:08:44 CST 2012
insert into wms_history_cargo_journal (deliver_time, log_date) binding parameter [1] as [TIMESTAMP] - 2012-09-13 11:08:44.25 binding parameter [2] as [TIMESTAMP] - Thu Sep 13 11:08:44 CST 2012
In my database server:
mysql> select timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00')); +----------------------------------------------------------------+ | timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00')) | +----------------------------------------------------------------+ | 08:00:00 | +----------------------------------------------------------------+
So, mysql timezone is right. UTC + 8
After choosing from mysql:
mysql> SELECT deliver_time, log_date FROM wms_history_cargo_journal; +---------------------+---------------------+ | deliver_time | log_date | +---------------------+---------------------+ | 2012-09-13 11:08:44 | 2012-09-13 03:08:44 | +---------------------+---------------------+
Error log_date!
source share