I have some errors from Date and Long types and Overlay Types. Both uses long which is not allowed in GWT JSNI. Date serializes as long via getTime().
What I am doing right now (and it seems to work) is:
FROM JAVA (Using Jackson to serialize to json)
Long myLong = new Long(50)
Date myDate = new Date();
public String getMyLong()
{
return String.valueOf(myLong);
}
public String getDate() {
return String.valueOf(date.getTime());
}
FROM GWT (Using OverlayTypes)
/*Returning a Long*/
private final native String _getEscaletaId() /*-{ return this.escaletaId; }-*/;
public final Long getEscaletaId() {return new Long(_getEscaletaId());}
/*Returning a Date*/
private final native String _getDate() /*-{ return this.date; }-*/;
public final Date getDate() {return new Date(Long.valueOf(_getDate()));}
Is this the better approach to deal with long and other special types?
Thankyou.
For dates, there's JsDate
, a thin JSO wrapper around the JS Date object.
Longs are dicey because JavaScript doesn't have the concept of a long. All numbers are 53-bit doubles, a fact which bit Twitter recently.
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