I have a problem using JAXB. I've created my Java Classes via xjc (using an xsd-schema) and has a global binding for the XML-Datatypes xs:date xs:dateTime and xs:time to java.util.Calendar with parse and print method.
Everything works fine until I marked some xs:date fields as nillable. The xjc creates JAXBElement wrappers for those properties. If these fields get unmarshaled the date is printed out including the time information which leads to validation errors.
Is there a possibilty to force the Marshaller to convert it to xs:date instead of xs:dateTime?
Can I specify a binding for those fields which gets a special XMLAdapater ewhich converts those fields?
The property inside the Java-Class looks like that:
@XmlElementRef(name = "dateField", namespace = "namespace", type = JAXBElement.class)
protected JAXBElement<Calendar> dateField;
and the corresponding xsd-looks like
<xs:element name="dateField" minOccurs="0" nillable="true" type="xs:date" />
Can someone help me please?
Thanks and best regards,
Arne
Do you really need to map the Calendar inside a JAXBElement?, wouldn't be correct to use the legacy XMLGregorianCalendar instead (and then you can convert it to a Date)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With