How do I convert String to Date or Date to String using GWT 2.0.3?
DateTimeFormatter formatter = DateTimeFormatter. forPattern("dd-MM-yyyy HH:mm:ss"); DateTime dateTime = DateTime. parse("22-Sep-2018 8:15:43", formatter);
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
.
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