In my overlays I wrap a JavaScript Date object in a JsDate:
public final native JsDate getDueDate() /*-{
return this["dueDate"];
}-*/;
However when I want to use that date in a widget, say a DateBox, I need to set the value as a Java Date. I could create a Java Date from my JsDate but I believe that adds some overhead.
Date javaDate = new Date(jsDate.getTime());
Is there a cleaner way of achieving this? What is the best way to convert a JsDate object to a Java Date object and vice-versa?
Thanks a lot
Jason's code doesn't work for me since getDueDateNative().getTime() returns a double and not a long. Therefore you have also to cast the value: return new Date((long) getDueDateNative().getTime());
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