View Full Version : Storing absolute dates

13 Aug 2010, 3:22 AM
Hi guys!

Maybe some of you have experienced a similar problem: How would one go about saving a date and time that shouldn't be interpreted as a timestamp (as in a absolute time) but rather as a date-string (just a date, without a timezone or a specific timestamp). The problem with using java.util.Date and GWT ist that on the client-side the timezone is read from the browser and the date is interpreted as an absolute time according to the current browser timezone.

Let me give you an example to illustrate the problem:
A user wants to enter a date and time of an incident that has happend somewhere. The date and time are in the timezone of the place where the incident happens, which in our case isn't the same timezone as specified by the user's browser. If you store that date and time in a java.util.Date object, it is interpreted as a time in the user's timezone and the result is that if the usere views it later when he's in a different timezone, the date has changed.

So my question is: How could you store such absolute dates? Using a String would be one way, but I rather would use something more sophisticated...

Another solution would be setting the GWT browser timezone to UTC. Is that possible?


18 Aug 2010, 5:18 AM
Do not use java.util.Date, use sting representation instead or your own object for holding day, month, year, hour, minute etc.
Or you can change Date serializer inside GWT