jaxb-v2 icon indicating copy to clipboard operation
jaxb-v2 copied to clipboard

JAXB does not support java.time.* types

Open LanceAndersen opened this issue 7 years ago • 1 comments
trafficstars

This refers to JDK issue https://bugs.openjdk.java.net/browse/JDK-8016742

FULL PRODUCT VERSION : java version " 1.8.0-ea " Java(TM) SE Runtime Environment (build 1.8.0-ea-b93) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b34, mixed mode)

ADDITIONAL OS VERSION INFORMATION : Windows 7 64-bit

A DESCRIPTION OF THE PROBLEM : There needs to be java.time support in JAXB. I have a POJO with an @XmlElement " lastModified " of type java.time.Instant, and it just gets printed out <lastModified /> (the value is ignored). It should be printed out ISO 8601-formatted (Instant.toString()). This should be the case for all ISO 8601-representable java.time types.

REPRODUCIBILITY : This bug can be reproduced always.

LanceAndersen avatar Apr 11 '18 21:04 LanceAndersen

Unfortunately, unlike JDBC, JAXB doesn't seem to support the new Date & Time API out-of-the-box.

Eg. there are no according methods in DatatypeConverter to easily create custom JAXB bindings: https://docs.oracle.com/javase/10/docs/api/javax/xml/bind/DatatypeConverter.html

puce77 avatar Apr 14 '18 19:04 puce77