Setup
- Web application runs on machine A with system time set to GMT
- Oracle database runs on machine B with system time set to GMT. (select dbtimezone from dual shows +0:00)
Problem
Web application uses Hades JPA and Hibernate to write and read from the DB. A table has two columns of type timestamp called CREATED and MODIFIED. The web applications uses joda DateTime to get java.util.Date object and writes it into the DB. Things are fine the first time the entry is created, both fields have time set in GMT. But once this same row gets updated the MODIFIED column gets set in PST.
It is the same code section that gets executed to set date values during creation as well as during modification (It tries getting java.util.Date from joda DateTime as mentioned above).
Can someone explain this behavior?
One more thing I have noticed is in the above setup if in the web application I set the date column using new Date(), it sets it in PST. I am clueless as where is it getting the timezone as PST when the application and DB are both running in machines set to GMT.
EDIT: TimeZone.getDefault() prints GMT in both the machines.