Java – the best way of storing date

google-app-enginejava

I am a new to storing dates based on time zones.

Need to know the standard way to store the date in the datastore.

My requirements are

  1. Easy to query the date based on the date range.
  2. show the date with the client appropriate time zone selected by him(I am having a table maintained for the timezone separately)
  3. Able to query using the datastore Admin console also.

Any suggestions/ideas regarding this will be a great help in proceeding further.

Best Answer

You might consider always storing the times in UTC. Then have your code logic handle conversions per timezone appropriately. IMO this is easier than trying to convert to other arbitrary timezones, and many code libraries have built-in options for UTC. This also has the benefit of still working if your data storage (database?) server is ever moved to a new location -- or even the cloud.

Related Topic