Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert String to Date on GWT

Tags:

gwt

How do I convert String to Date or Date to String using GWT 2.0.3?

like image 890
user312796 Avatar asked Aug 22 '10 23:08

user312796


People also ask

How to convert DateTimeFormatter to date in java?

DateTimeFormatter formatter = DateTimeFormatter. forPattern("dd-MM-yyyy HH:mm:ss"); DateTime dateTime = DateTime. parse("22-Sep-2018 8:15:43", formatter);


1 Answers

With the methods on the java.util.Date class itself: parse(String s) and toString(). Although the first is deprecated it is the method to use with GWT. If you want more control over how the Date is formatted, when converting to String use the GWT specific class: com.google.gwt.i18n.client.DateTimeFormat. It will format the date given a pattern, similar to Java's own SimpleDateFormat.

like image 148
Hilbrand Bouwkamp Avatar answered Oct 21 '22 11:10

Hilbrand Bouwkamp