流易

日日行,不怕千万里;常常做,不怕千万事。(https://github.com/poazy)

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

 

posted on 2018-07-02 16:43  流易  阅读(380)  评论(0编辑  收藏  举报