I have a Joda DateTime date in the Order class:
public class Order { private DateTime creationTime; ... }
I initialized my cartographer as follows:
mapper.configure( SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
When I serialize this class, I expect to see serialTime serialized in ISO-8601 format as follows
{ "creationTime" : "2011-01-01T09:00:00.000-04:00" }
This works fine in my unit test. However, in my web application, exactly the same code serializes all DateTime fields:
{ "creationTime" : { "year" : 2011, "dayOfMonth" : 17, "dayOfWeek" : 7, "era" : 1, "dayOfYear" : 107, "weekOfWeekyear" : 15, "weekyear" : 2011, "monthOfYear" : 4, "yearOfEra" : 2011, "yearOfCentury" : 11, "centuryOfEra" : 20, "millisOfSecond" : 590, "millisOfDay" : 40311590, "secondOfMinute" : 51, "secondOfDay" : 40311, "minuteOfHour" : 11, "minuteOfDay" : 671, "hourOfDay" : 11, "millis" : 1303053111590, "zone" : { "fixed" : false, "uncachedZone" : { "cachable" : true, "fixed" : false, "id" : "America/New_York" }, "id" : "America/New_York" }, "chronology" : { "zone" : { "fixed" : false, "uncachedZone" : { "cachable" : true, "fixed" : false, "id" : "America/New_York" }, "id" : "America/New_York" } } }
What am I missing? In both cases, I include jackson-core-asl-1.7.6.jar and jackson-mapper-asl-1.7.6.jar in my classpath.
In some online examples, I saw the annotation in DateTime. I do not know if this is necessary, but I tried this irresponsibility. See below:
public class Order { @JsonSerialize(using=DateTimeSerializer.class) private DateTime creationTime; ... }
It does not matter.
Thanks.
PS Does anyone know if Jackson's mailing list works? I posted this question on the user mailing list, but it does not appear in the archives. The last message in the archive is dated June 24, 2010.