jaxb-bindings.xml配置:
<?xml version="1.0" encoding="UTF-8"?> <jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"> <jaxb:globalBindings generateElementProperty="false"> <!-- use Calendar instead of XMLGregorianCalendar --> <jaxb:javaType name="java.util.Calendar" xmlType="xs:dateTime" parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" printMethod="javax.xml.bind.DatatypeConverter.printDateTime"/> <jaxb:javaType name="java.util.Calendar" xmlType="xs:date" parseMethod="javax.xml.bind.DatatypeConverter.parseDate" printMethod="javax.xml.bind.DatatypeConverter.printDate"/> <jaxb:javaType name="java.util.Calendar" xmlType="xs:time" parseMethod="javax.xml.bind.DatatypeConverter.parseTime" printMethod="javax.xml.bind.DatatypeConverter.printTime"/> <!-- use Calendar Date instead of XMLGregorianCalendar <jaxb:javaType name="java.util.Date" xmlType="xs:dateTime" parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDateTime" printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime"/> <jaxb:javaType name="java.util.Date" xmlType="xs:date" parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDate" printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDate"/> <jaxb:javaType name="java.util.Date" xmlType="xs:time" parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseTime" printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printTime"/> --> </jaxb:globalBindings> </jaxb:bindings>
转载:
https://stackoverflow.com/questions/21287429/unable-to-generate-java-util-calendar-from-xsd-getting-xmlgregoriancalendar
https://stackoverflow.com/questions/12513361/jaxb-custom-bindings-adapter1-class-and-joda-time/27380200