Skip to content

Java Entities Dates fields and Oracle TIMESTAMP data types

In my entities classes I use to define the temporal fields as follows:

    @Column(name = "START_DATE")
    private Date start;

In my oracle DB the columns mapped by those fields are of type TIMESTAMP.

What are the implications of this configurations:
Are my dates implicitily UTC dates ?
Does it mean I have to be careful on handling by myself Daylight saving time issues ?


The JPA TemporalType.TIMESTAMP corresponds to the JDBC java.sql.Timestamp type, which in turn corresponds to Oracle’s (and the SQL standard) TIMESTAMP [ WITHOUT TIME ZONE ] type. While JDBC 4.2 (Java 8) added support also for OffsetDateTime, Java EE 7’s TemporalType is not there yet.

This means that your values do not have any time zone attached to them, the semantics of the timestamp is that of the “local time zone”, whatever that is configured to be. Of course, you have to watch out for potentially different server (database) and client (machine running your Java application) “local time zones”!

You can achieve the desired behaviour if you are sure that client and server time zones are set to UTC.