I created a RESTful web service using JAX-RS method annotations:
@GET
@Path("/test")
@Produces(MediaType.APPLICATION_JSON)
public MyThing test()
{
MyThing myObject = new MyThing(LocalDateTime.now());
return myObject;
}
This works nicely, but I'd like to adjust one thing: If the returned Java object contains a property of the new Java 8 LocalDateTime type, it is represented as a JSON object:
{"myDateTimeProperty":{"hour":14,"minute":32,"second":39,"year":2014,"month":"NOVEMBER","dayOfMonth":6,"dayOfWeek":"THURSDAY","dayOfYear":310,"monthValue":11,"nano":0,"chronology":{"calendarType":"iso8601","id":"ISO"}},...}
How can I tell JAX-RS to return a JavaScript Date.toJSON()-style String like
{"myDateTimeProperty":"2014-11-07T15:06:36.545Z",...}
instead?