Imagine I store everything on the server according to the server's date. However, when the us开发者_JS百科er tries to access these data from the server, the user might be not in the same timezone as the server. So, basically when the user receives data from the server, I want the data's date to be converted to user's timezone. How can I do this in gwt, considering I'm receiving a Date object from the server? Any links or suggestions are highly welcome.
Thank you.
A java.util.Date
object doesn't have a time zone. It's a moment in time, and can be formatted using a specific time zone in order to be readable by humans. The DateTimeFormat documentation seems to indicate that it handles the browser time zone. It also has a format method taking a TimeZone as argument.
GWT is not going to be that helpful, you should translate dates between timezones yourself and then pass the objects to the GWT layer to display them correctly. You should use Calendar
to jump between timezones, have a look here for some ideas.
精彩评论