gwt:没有可用于 java.util.Calendar 类型的源代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4170827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gwt: No source code is available for type java.util.Calendar
提问by user468587
I tried to use java.util.Calendar
in my GWT application as following:
我尝试java.util.Calendar
在我的 GWT 应用程序中使用如下:
Calendar cal = Calendar.getInstance();
then i got this error:
然后我收到了这个错误:
No source code is available for type
java.util.Calendar
; did you forget to inherit a required module?
type 没有可用的源代码
java.util.Calendar
;您是否忘记继承所需的模块?
anyone know what's wrong with it?
有谁知道有什么问题吗?
回答by drekka
I would not have thought you would need the source code although I've never used SWT. But at no time when using any one of a wide range of Java apis have I ever had this message just trying to use a class from them. So I think it's either an incorrect message or you have done something in the IDE that is trying to show you the source code. You can find a zip of the source on the JDKs directories. Id's such as Eclipse have the ability to associate source code zips with jars so that they can automatically look up source when you trigger that action.
虽然我从未使用过 SWT,但我没想到您会需要源代码。但是在使用各种 Java api 中的任何一个时,我从来没有收到过这条消息,只是试图使用它们中的一个类。所以我认为这要么是一条不正确的消息,要么是您在 IDE 中做了一些试图向您展示源代码的事情。您可以在 JDK 目录中找到源代码的 zip。诸如 Eclipse 之类的 ID 能够将源代码 zip 与 jar 相关联,以便在您触发该操作时它们可以自动查找源代码。
回答by Sudhir Jonathan
The Calendar class depends on a lot of Java classes that GWT cannot possibly convert to Javascript. If it fits your needs, you could simply do new Date()
on the client side. See herefor more details.
Calendar 类依赖于许多 GWT 不可能转换为 Javascript 的 Java 类。如果它符合您的需求,您可以简单地new Date()
在客户端进行。请参阅此处了解更多详情。
You could also try the gwt-calendar project.
您也可以尝试gwt-calendar 项目。
回答by Riley Lark
java.util.Date will still work, and you can use com.google.gwt.i18n.client.DateTimeFormatto do any date formatting you need to do.
java.util.Date 仍然有效,您可以使用com.google.gwt.i18n.client.DateTimeFormat进行任何您需要进行的日期格式化。
Check that link for full example code.
检查该链接以获取完整的示例代码。
回答by Yusuf K.
Calender class is not supported from GWT, You must use Date class instead of Calender.
GWT 不支持日历类,您必须使用日期类而不是日历。
回答by Adelin
https://developers.google.com/web-toolkit/doc/latest/RefJreEmulationyou can't use everything in GWT .... !
https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation你不能在 GWT 中使用所有东西......!
回答by appbootup
The relevant bug is logged in GWT since GWT version 1.3 and you can find it here - http://code.google.com/p/google-web-toolkit/issues/detail?id=603
自 GWT 1.3 版以来,相关错误已记录在 GWT 中,您可以在此处找到它 - http://code.google.com/p/google-web-toolkit/issues/detail?id=603
1) The Calendar class support for GWT is a long pending request from GWT User community.
1) GWT 的 Calendar 类支持是来自 GWT 用户社区的长期未决请求。
2) Unfortunately GWT team has decided we can do without it.
2)不幸的是 GWT 团队已经决定我们可以没有它。
You can find all possible discussions on Google GWT forum. There are other alternatives which you look up in the forum and the issue discussion thread runs into a few pages.
您可以在 Google GWT 论坛上找到所有可能的讨论。您可以在论坛中查找其他替代方案,问题讨论主题长达几页。
Essentially we decided to do away with any client side code using Calendar and just handle the stuff on server side.
本质上,我们决定取消使用 Calendar 的任何客户端代码,只处理服务器端的内容。