tags:

views:

33

answers:

1

We use the following call to set the Date value and store it in the database.

setCreationDate(new java.util.Date());

Assuming our database server is in PST timezone and user1 (in PST), user2 (in EST), user3 (in GMT). The user screen gets rendered based on timezone properly.

If I move the database data to a different timezone (say EST), will the behavior remain the same or should I store the date value in GMT itself prior to storage. If so how should I address this?

A: 

Date-Times should always be stored as UTC (a.k.a. Zulu Time, GMT). It could be argued that there is one and only one time on this planet and everything else is an interpretation of that to local custom and convenience.

That the Royal Observatory, Greenwich is the place where the real-time matches with the sun is an historical accident, but has proven useful over the last few hundred years (and to be precise, even the sun isn't a great standard, whence UTC, but the general point still holds).

See http://stackoverflow.com/questions/230126/how-to-handle-calendar-timezones-using-java for Java details.

msw