1

We are unmarshalling date field using JAXB. The format that is coming in the xml is like

2013-10-07 03:57:36.703

In my DTO class, the field where this value has to be populates looks like

@XmlElement(name = "VALID_TO", required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar validto;

But, after unmarshalling, I don't get anything in valito.

In the xsd, VALID_TO has a custom xsd:date mapping with pattern[0-9]{4}-[0-9]{2}-[0-9]{2}

Is it necessary to have timeZone in the value to be able to convert to XmlGregorianCalendar ?

Thanks !!!

Shaggy
  • 97
  • 3
  • 13
  • possible duplicate of [jaxb unmarshal timestamp](http://stackoverflow.com/questions/2519432/jaxb-unmarshal-timestamp) – bdoughan Oct 07 '13 at 13:26

1 Answers1

0

The following formats will work with JAXB and XMLGregorianCalendar out of the box.

  • xsd:date - 2013-10-07
  • xsd:dateTime - 2013-10-07T03:57:36.703

If you want an alternate format such as 2013-10-07 03:57:36.703 you can use an XmlAdapter.

Community
  • 1
  • 1
bdoughan
  • 147,609
  • 23
  • 300
  • 400