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?
SimpleDateFormat
is not available in GWT. Use com.google.gwt.i18n.client.DateTimeFormat instead.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With