1

when unmarshalling from xml, can we map the date object or calendar object?

user496949
  • 79,431
  • 144
  • 301
  • 419

3 Answers3

2

I assume you're talking about JAXB here? If so then yes. Just use the javaType binding declaration in your JAXB bindings. See here: http://download.oracle.com/javaee/5/tutorial/doc/bnbbf.html

Simeon G
  • 1,179
  • 8
  • 20
  • 1
    Also see this other stackoverflow question and its solution: http://stackoverflow.com/questions/3679266/simple-conversion-between-java-util-date-and-xmlgregoriancalendar – Simeon G Mar 10 '11 at 02:09
1

Yes. According to the mapping table on this page, xsd:date maps to XMLGregorianCalendar.

Bala R
  • 104,615
  • 23
  • 192
  • 207
1

You can map to Calendar, Date, or XMLGregorianCalendar:

You can leverage the @XmlSchemaType annotation to choose the XML format: xsd:date, xsd:dateTime, xsd:time, etc.

bdoughan
  • 145,155
  • 22
  • 291
  • 386