Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Source Code is available for type java.text.SimpleDateFormat: GWT Compilation Error

Tags:

java

gwt

I was trying to make a GWT application. Then I got some errors when using SimpleDateFormat class in client and shared side.

[ERROR] [gwtfirst] Line 381: No source code is available for type java.text.SimpleDateFormat; did you forget to inherit a required module?

following is my code in client side:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
Window.alert(sdf.format(usersList.get(30).getCreatedate()));

But I can use SimpleDateFormat with server side... I'm wondering if I can't use SimpleDateFormat in client or shared side?

like image 718
Mozzan Avatar asked Aug 09 '13 02:08

Mozzan


2 Answers

SimpleDateFormat is not available in GWT. Use com.google.gwt.i18n.client.DateTimeFormat instead.

like image 50
tibtof Avatar answered Oct 21 '22 12:10

tibtof


GWT does not contain SimpleDateFormat instead it have DateTimeFormat So you can use

 DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("YYYY/MM/DD") 
 Date date = dateTimeFormat.parse(str);

for more read "com.google.gwt.i18n.client.DateTimeFormat".

like image 37
Sagar Argade Avatar answered Oct 21 '22 13:10

Sagar Argade