Support for custom time zones in GWT

43 views
Skip to first unread message

Alexander Orlov

unread,
Jul 13, 2012, 10:56:36 AM7/13/12
to google-we...@googlegroups.com
GWT's Date object operates just like its JavaScript counterpart in a user's system time zone. Is there a way to override GWT's Date object time zone? Creating something like 
 
   
public class FakeDate extends Date { 
public FakeDate(String timeZoneConstantJson) {
        FakeDate.timeZoneConstantJson = timeZoneConstantJson;
        TimeZoneInfo timeZoneInfo = TimeZoneInfo.buildTimeZoneData(FakeDate.timeZoneConstantJson);
        TimeZone timeZone = TimeZone.createTimeZone(timeZoneInfo);
        int currentDateOffsetInMin = timeZone.getOffset(this);
        FakeDate.currentDateOffsetInMs = currentDateOffsetInMin * 60 * 1000; 

        super.setTime(super.getTime() - FakeDate.currentDateOffsetInMs);
    }

...doesn't work with RequestFactory proxy classes because they expect the Date super class instead of the FakeDate subclass just like the model classes that have a Date field (which has to stay for reasons that would take a while to explain :).
Reply all
Reply to author
Forward
0 new messages