I'm using Jersey (jax-rs), to build a REST rich application.
Everything is great, but I don't really understand how to configure the JSON Marshalling/Unmarshalling options for dates and numbers.
I have a User class:
@XmlRootElement
public class User {
private String username;
private String password;
private java.util.Date createdOn;
// ... getters and setters
}
When the createdOn
property is serialized, I get a string like this: '2010-05-12T00:00:00+02:00', but I need to use a specific date pattern, both to marshall and unmarshall dates.
Does someone know how to do that?
What you get is a date ISO 8601 format, which is a standard. Jersey will parse it for you on the server. For javascript here is an extension to js date to parse that.
Update Link is dead: try another parser, see Help parsing ISO 8601 date in Javascript