Saturday, April 16, 2011

Date Operations in GWT

Standard java class java.util.Calendar does not work in GWT. Instead, use GWT class com.google.gwt.user.datepicker.client.CalendarUtil.



Similarly, for formatting and parsing date/time, use com.google.gwt.i18n.client.DateTimeFormat


Convert Date to String - Format

DateTimeFormat.PredefinedFormat.DATE_SHORT).format(newDate())



Convert String to Date - Parse

DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_SHORT).parse(dateString)










No comments:

Post a Comment