0

I want to provide TimeZone settings in application, So, I need to get the Time Zones from the browser using smart Gwt. Please tell me the methods for getting time zones. Actually I have written java coding in smart gwt application as follows,

String timezones[]=java.util.TimeZone.getAvailableIDs();

for(int i=0;i<(timezones.length)-1;i++)
{

System.out.println(timezones[i]);

}

but it is not worked out and it is throwing an Exception as follows:

  1. [ERROR] [timezoneproject] Line 32: No source code is available for type java.util.TimeZone; did you forget to inherit a required module

  2. [ERROR] [timezoneproject] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly

How can I solve this?

RAS
  • 8,100
  • 16
  • 64
  • 86

3 Answers3

2

GWT do support TimeZone.

Refer the com.google.gwt.i18n.client.TimeZoneConstants interface for list for TimeZones

can be found here

Also Find the Test program here

TO Create Timezone in GWT

final TimeZoneConstants timeZoneConstants = GWT.create(TimeZoneConstants.class);

TimeZone usPacific = TimeZone.createTimeZone(
        TimeZoneInfo.buildTimeZoneData(timeZoneConstants.americaLosAngeles()));
swiftBoy
  • 35,607
  • 26
  • 136
  • 135
1

As Jean-Michel Garcia said, you cannot run the TimeZone class methods on the client side of your GWT application.

Instead, you should call String timezones[]=java.util.TimeZone.getAvailableIDs(); on the server-side of GWT and return the string array to the client and then do whatever you want with it

Adel Boutros
  • 10,205
  • 7
  • 55
  • 89
0

TimeZone is not part of the GWT emulated JRE. Therefore, you can't use it.

Please see this link : https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation#Package_java_util

Jean-Michel Garcia
  • 2,359
  • 2
  • 23
  • 44