简体   繁体   中英

How can I get a date object from server (appengine) and convert it to client's timezone's date (gwt)?

Imagine I store everything on the server according to the server's date. However, when the user 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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM