3

Now that java.util.Date is almost entirely deprecated and GWT does not emulate the new util java.util.Calendar I am not sure if it's a big fun to work with time on the GWT client side.

I know that there are "options" but those were not maintained over years. Also the GWT CalendarUtil is entirely relying on java.util.Date and therefore has to be enjoyed with care.

So what should I use on the client side for time handling in GWT?

Community
  • 1
  • 1
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378

1 Answers1

4

Until we have Java 8 and java.time, the way to go is still java.util.Date, with appropriate @SuppressWarnings. Either that or dealing with numeric timestamps or GWT's JsDate, or possibly wrapping some JS libs.

JS itself is quite limited when it comes to date time handling, hence GWT's limitations too.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • Okay, I see! If I may ask: Do you know if the GWT [`CalendarUtil`](http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/datepicker/client/CalendarUtil.html) is going to stay the way it is and just its implementation is going to change? I am asking because `CalendarUtil` itself is not `@deprecated` but the `java.util.Date` it's currently using is. Am I assuming right that you guys are just going to change its implementation but not the interface? – Stefan Falk Aug 21 '15 at 08:45
  • 1
    `CalendarUtil` is very likely to stay the same, and not even be updated to `java.time`, even internally. – Thomas Broyer Aug 21 '15 at 08:55