Automatically determine browser time zone?
Posted on 2006-04-12
I'm developing an application that will be used worldwide. I think I need to handle and store all dates on the server in GMT time, so I can use TimeZone.setDefault() to set all times to "GMT". Is that the best approach? If so, then so far, so good.
Now, how do I display dates and times on a JSP page in the user's time zone? I have read up on <fmt:formatDate> and the various time zone tags, but they all assume that I give them the time zone to use. I don't know what time zone the user is in. Isn't that something that can be determined by the browser?
Also, when the user inputs a date without a time into a JSP form, how do I convert that back to GMT if I don't know the user's time zone?