I have a WSDL that specifies an element\'s type to be xs:date.
When I use Apache CXF to generate the Java classes, it renders the variable as an javax.xml.datatype.XMLGr
To complete Filip answer (thanks to him!), maybe it will help some of you ...
I had to declare a new XmlAdapter on the concern field date with the annotation @XmlJavaTypeAdapter
public class YourDTO {
// ...
@XmlElement
@XmlSchemaType(name = "dateTime")
@XmlJavaTypeAdapter(type = XMLGregorianCalendar.class, value = XmlDateAdapter.class)
public Date yourDate;
// ...
}
The adapter
public class XmlDateAdapter extends XmlAdapter {
@Override
public XMLGregorianCalendar marshal(Date date) throws Exception {
GregorianCalendar gcal = new GregorianCalendar();
gcal.setTime(date);
XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
xmlDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
return xmlDate;
}
// ...
SOAP message date format before
2017-04-18T00:00:00+02:00
SOAP message date format after
2017-04-18T00:00:00