0

I got a simple question:

Having such an entity

@Entity
public class Entity {
    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Temporal(TemporalType.TIMESTAMP)
    private Date created = new Date();
}

If I saved one with a server having GMT+4 for TimeZone, with a UTC DB server

Entity entity = new Entity();
entityDao.save(entity);

What is really saved? Does Hibernate convert the GMT+4 into UTC when saving?

farvilain
  • 2,552
  • 2
  • 13
  • 24

1 Answers1

0

Ok, the easy way is to have mysql in UTC:

/etc/mysql/my.cnf

[mysqld]
default-time-zone = '+00:00'

And set the JAVA_OPTS for the tomcat : -Duser.timezone=GMT

farvilain
  • 2,552
  • 2
  • 13
  • 24