Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gwt: No source code is available for type java.util.Calendar

Tags:

java

gwt

I tried to use java.util.Calendar in my GWT application as following:

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?

anyone know what's wrong with it?

like image 554
user468587 Avatar asked Nov 13 '10 03:11

user468587


5 Answers

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

1) The Calendar class support for GWT is a long pending request from GWT User community.

2) Unfortunately GWT team has decided we can do without it.

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.

Essentially we decided to do away with any client side code using Calendar and just handle the stuff on server side.

like image 129
appbootup Avatar answered Oct 03 '22 05:10

appbootup


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 here for more details.

You could also try the gwt-calendar project.

like image 30
Sudhir Jonathan Avatar answered Oct 03 '22 05:10

Sudhir Jonathan


Calender class is not supported from GWT, You must use Date class instead of Calender.

like image 28
Yusuf K. Avatar answered Oct 03 '22 04:10

Yusuf K.


java.util.Date will still work, and you can use com.google.gwt.i18n.client.DateTimeFormat to do any date formatting you need to do.

Check that link for full example code.

like image 42
Riley Lark Avatar answered Oct 03 '22 05:10

Riley Lark


https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation you can't use everything in GWT .... !

like image 21
Adelin Avatar answered Oct 03 '22 05:10

Adelin