Can JAXB handle java.time objects?

后端 未结 2 955
我在风中等你
我在风中等你 2020-12-05 18:33

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.ti

2条回答
  •  有刺的猬
    2020-12-05 18:52

    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.

提交回复
热议问题