How to format timestamp in GWT app with given timezone?
I have to format date/time in my gwt app with specific timezone, which is loaded from the server. Possible timezones are like this GMT, GMT+1, GMT-2 etc... Up to now i used DateTimeFormat to format my timestamps, and they used client's locale.
PLease help.开发者_如何学JAVA
You can format in any timezone you want with DateTimeFormat
, you just have to pass it as the second argument to the format
method.
And to obtain a TimeZone
object, depending on how you want to present the timezone information (if ever) in the formatted date/time, you can use either createTimeZone(int)
or createTimeZone(String)
(getting the string out of TimeZoneConstants
).
精彩评论