I have a Spring MVC project that accepts XML input via a the PUT method. One of the elements in the XML is a dateTime
. I am using a Jaxb2Marshaller
to unmarshal the XML into a bean. I have a unit test that runs against the webapp running on a server.
When I send in a timestamp using new GregorianCalendar(2012, 01, 02)
everything works well and my application receives the Object.
However, if I update my test to use new GregorianCalendar(2013, 01, 02)
that field in the Object is returned as null
.
Notice that the only difference is the year, 2012 vs 2013. I do not see any error messages in the application log, localhost or catalina.out.
Thoughts?
Edit: Additional Info...
I am using the DataTypeConverter
to convert from dateTime
to Calendar
. So my schema has the following (and I am using XJC to convert the schema to Java classes).
<annotation><appinfo><jaxb:globalBinding>
<jaxb:javaType name="java.util.Calendar" xmlType="dateTime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
printMethod="javax.xml.bind.DatatypeConverter.pringDate"/>
</jaxb:globalBinding></appinfo></annotation>
So I got rid of the mapping to Calendar
and allowed XJC to produce the Java classes with XMLGregorianCalendar
. This seemed to resolve the issue. Still seems strange so am open to insight.