Running GWT.create in the TimeZoneConstants class is a bad game according to the GWT Javadoc [1]. So what I did was create a server-side class that parses / com / google / gwt / i 18n / client / constants / TimeZoneConstants.properties and creates a cache of all JSON objects for each time zone (their Olson TZID is indexed).
My site runs on jboss, so I copied TimeZoneConstants.properties to my war / WEB-INF / lib directory on my site (probably it didn’t need to be copied, since there are already GWT banks). Then I have a singleton class that does parsing when building:
InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(PROPERTIES_FILE); InputStreamReader isr = new InputStreamReader(inStream); BufferedReader br = new BufferedReader(isr); for (String s; (s = br.readLine()) != null;) {
Finally, I make an RPC call to get TimeZoneInfoJSON for the client (if the server knows which TimeZoneID is interesting to me):
getTimeZone(new PortalAsyncCallback<String>() { public void onSuccess(String tzJson) { timeZone = TimeZone.createTimeZone(TimeZoneInfo.buildTimeZoneData(tzJson)); } });
Not the most elegant solution, but it gave me a way to display dates and times for a specific time zone on DST transitions.
[1] http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/i18n/client/constants/TimeZoneConstants.html
source share