I want to change "javax.xml.datatype.XMLGregorianCalendar" to "java.util.Date" when unmarshalling from xml to Java class of JAXB.
But I don't put any annotations of @XmlJavaTypeAdapter in Java classes.
So, I'm going to try to use an annotation of @XmlJavaTypeAdapters, but I don't know how to use it...
Please show me examples for using it.
As an interesting aside, you don't actually need to adapt XMLGregorianCalendar to Date, since JAXB supports java.util.Date natively -- like this:
If you need it, @XmlJavaTypeAdapter can work like this, assuming your custom class:
You need a class which JAXB can understand, and then write an adapter between that class and the custom class, like this:
Now you can use that in your own classes, like this:
There are plenty of good examples of using the @XmlJavaTypeAdapter available on the net, like this one and this one, and several others. Happy adapting!