Why does "xsd:date" of XML Schema Type mapped "javax.xml.datatype.XMLGregorianCalendar" When Schema-to-Java Mapping of JAXB does
I don't know why does "xsd:date" of XML Schema Type mapped "javax.xml.datatype.XMLGregorianCalendar" When Schema-to-Ja开发者_开发百科va Mapping of JAXB does.
Why does "xsd:date" of XML Schema Type mapped "java.util.Date" ?
I guess that JAXB intentionally does its mapping. I want to know that reason if any.
And if exists it, how to change "xsd:date" of XML Schema Type to "java.util.Date" of Java class without using annotation(ex.@XmlJavaTypeAdapter).
I want to do mashalling and unmarshalling without all annotations.
Couple of reasons
- java.util.Date doesn't handle TimeZone's
- So that it can handle ISO 8601 date-time format which can't be handled by built-in Calendar class. For e.g the months are from 1-12 but in Calendar/Date 0-12. Sometimes when querying you might want to get the first month as 1 and not 0.
When starting from Java classes you can use any "date" datatype. When starting from XML schema will generate XMLGregorianCalendar because it preserves all the temporal information (including time zone). Of course you can always modify the generated objects or annotate the schema to generate different types.
For more information:
- http://bdoughan.blogspot.com/2011/01/jaxb-and-datetime-properties.html
精彩评论