I know JAXB (Java Architecture for XML Binding) can marshal/unmarshal java.util.Date objects as seen in this answer by Blaise Doughan.
But what about the new java.time package objects in Java 8, such as ZonedDateTime
? Has JAXB been updated to handle this newly built-in data type?
In Java SE 8, JAXB has not been updated yet to support the java.time types.
Indeed, there is an issue related to this in the reference implementation.
You need to create and use an XmlAdapter
to handle those types. Use an approach similar to that done with Joda-Time as described in this posting, JAXB and Joda-Time: Dates and Times.
You may be able to use this implementation of adapters for java.time.