2

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

    @Temporal(TemporalType.TIMESTAMP)
    @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 ?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

10 Comments

thanks! please can you elaborate a little bit more on what you said about "the semantics is that of the "local time zone""
When you say client and server you mean Application server and RDBMS?
@GionJh: Edited to make this more clear. I strongly suggest you read up the documentation about this.
Yeah thanks I'm a little bit confused also because I thought java.util.Date only refers to UTC timezone and not your system time zone, is it right ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.