I am using "Full Data Binding" in Jackson to deserialize a date in a JSON string.
The format these dates are coming is "EEE MMM dd HH:mm:ss zzz yyyy".
I'm using Jackson 1.8 and I cannot figure out how to configure the ObjectMapper so it would deserialize these Strings properly into JODA DateTime objects.
Snippet from the POJO:
private DateTime deliveryTime;
@JsonProperty("DeliveryTime")
public void setDeliveryTime(DateTime deliveryTime) {
this.deliveryTime = deliveryTime;
}
@JsonProperty("DeliveryTime")
public DateTime getDeliveryTime() {
return deliveryTime;
}
Thanks.
Best Answer
The simplest way to configure ObjectMapper to use specific date/time format is to call
ObjectMapper.setDateFormat(...)
method.There are some preliminary plans in creating a new Joda datatype Jackson module, as that would make it much easier to add powerful new configuration; current challenge being that Jackson itself should not have hard (static) dependency to external libraries (as much as I like Joda personally!), which limits degree to which lib-specific configurability can work.