我希望在应用程序中提供TimeZone设置,因此,我需要使用智能Gwt从浏览器中获取时区。请告诉我获取时区的方法。实际上,我在智能gwt应用程序中编写了java代码,如下所示,
String timezones[]=java.util.TimeZone.getAvailableIDs();
for(int i=0;i<(timezones.length)-1;i++)
{
System.out.println(timezones[i]);
}但是它没有得到解决,它抛出了一个例外情况如下:
[ERROR] [timezoneproject] Line 32: No source code is available for type java.util.TimeZone; did you forget to inherit a required module[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我怎么才能解决这个问题?
发布于 2012-06-11 07:10:37
GWT支持TimeZone。
参考com.google.gwt.i18n.client.TimeZoneConstants接口获取TimeZones的列表
可以找到这里
还可以找到测试程序这里
在GWT中创建Timezone
final TimeZoneConstants timeZoneConstants = GWT.create(TimeZoneConstants.class);
TimeZone usPacific = TimeZone.createTimeZone(
TimeZoneInfo.buildTimeZoneData(timeZoneConstants.americaLosAngeles()));发布于 2012-06-06 16:28:18
正如Jean所说,您不能在GWT应用程序的客户端运行TimeZone类方法。
相反,您应该在GWT的服务器端调用String timezones[]=java.util.TimeZone.getAvailableIDs();,并将字符串数组返回给客户端,然后对它做您想做的任何事情。
发布于 2012-06-06 09:09:36
TimeZone不是GWT仿真JRE的一部分。因此,你不能使用它。
请参阅以下链接:实用程序
https://stackoverflow.com/questions/10909193
复制相似问题