How to user java.util.Calendar in GWT

1,941 views
Skip to first unread message

~Pun~

unread,
Jun 27, 2008, 3:36:55 AM6/27/08
to Google Web Toolkit
I use GWT version 1.5 and I want to use java.util.Calendar in method
onModuleLoad my code:

public void onModuleLoad() {
Calendar cal = Calendar.getInstance();
}

and my error:
No source code is available for type java.util.Calendar; did you
forget to inherit a required module?

How to I add java.util.Calendar in my module.

kilkenny

unread,
Jun 27, 2008, 7:55:48 AM6/27/08
to Google Web Toolkit
Hi Pun

I am not yet familiar with GWT 1.5... But the Calendar class is
missing from the JRE emulation library in GWT 1.4. So I assume it is
also missing in GWT 1.5. You can use the DateTimeFormat class to
handle and format date objects.

http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/i18n/client/DateTimeFormat.html

What classes can be used in client-side code can be checked in the
documentation:
http://code.google.com/webtoolkit/documentation/jre.html

Regards, Adrian
--
http://traceurl.com

_marwis_

unread,
Jun 27, 2008, 5:04:39 AM6/27/08
to Google Web Toolkit
If you want to use java.util.Calendar in your GWT app, you have to
tell GWTCompiler to compile this class and all dependencies to js. Try
to add new source path into your .gwt.xml config file.

Punnawat Tadapak

unread,
Jun 28, 2008, 3:46:04 AM6/28/08
to Google-We...@googlegroups.com, marwi...@gmail.com
Please tell me about detail step by step or example.
Because I just coding with GWT

Thanks,
Pun

walden

unread,
Jun 29, 2008, 8:23:34 AM6/29/08
to Google Web Toolkit
No, forget about java.util.Calendar in your GWT application. Stick
with java.util.Date, and use the deprecated methods if you need date
computations.
> > to add new source path into your .gwt.xml config file.- Hide quoted text -
>
> - Show quoted text -

ppa...@gmail.com

unread,
Jun 30, 2008, 10:00:23 AM6/30/08
to Google Web Toolkit
If you need more than the basic date computations, you can use the
Gwittir library (http://code.google.com/p/gwittir/) which has just
added support for Joda (http://joda-time.sourceforge.net/) which, in a
nutshell, is Java Date/Time done right.

Punnawat Tadapak

unread,
Jun 30, 2008, 10:48:45 AM6/30/08
to Google-We...@googlegroups.com
Thanks
Reply all
Reply to author
Forward
0 new messages