Note that there are some explanatory texts on larger screens.

plurals
  1. POcan we enforce restrictions on jaxb globalbindings for mapping xs:dateTime to java.util.Date
    primarykey
    data
    text
    <p>I have 3 schemas, each has xs:dateTime. To represent xs:dateTime as java.util.Date in java jaxb objects, i am using binding.xjb which looks as below</p> <pre><code>&lt;bindings schemaLocation="schema1.xsd"&gt; &lt;schemaBindings&gt; &lt;package name="com.mycompany.ims.schema1" /&gt; &lt;/schemaBindings&gt; &lt;/bindings&gt; &lt;bindings schemaLocation="schema2.xsd"&gt; &lt;schemaBindings&gt; &lt;package name="com.mycompany.ims.schema2" /&gt; &lt;/schemaBindings&gt; &lt;/bindings&gt; &lt;bindings schemaLocation="schema3.xsd"&gt; &lt;schemaBindings&gt; &lt;package name="com.mycompany.ims.schema3" /&gt; &lt;/schemaBindings&gt; &lt;/bindings&gt; &lt;globalBindings&gt; &lt;javaType name="java.util.Date" xmlType="xs:dateTime" parseMethod="com.mycompany.ims.utils.JaxbDateAdapter.parseDateTime" printMethod="com.mycompany.ims.utils.JaxbDateAdapter.printDateTime" /&gt; &lt;javaType name="java.util.Date" xmlType="xs:date" parseMethod="com.mycompany.ims.utils.JaxbDateAdapter.parseDate" printMethod="com.mycompany.ims.utils.JaxbDateAdapter.printDate" /&gt; &lt;/globalBindings&gt; </code></pre> <p>If i generate jaxb objects, all the xs:dateTime elements are represeted as java.util.Date. I have a requirement where in one of the schema (say schema1.xsd) i donot want to represent the xs:dateTime element as java.util.Date. </p> <p>Is there any way i can configure to restrict for particular schema or based on node name? Can any one help.</p> <p>I resolved the issue by adding the below xjb configuration, I edited the post to help the people who faced the same problem like mine</p> <pre><code>&lt;bindings schemaLocation="schema1.xsd"&gt; &lt;bindings node="//xs:complexType[@name='ApplicationHeader1']"&gt; &lt;bindings node=".//xs:element[@name='CreDt']"&gt; &lt;javaType name="java.util.Date" parseMethod="com.mycompany.ims.utils.JaxbDateAdapter.parseUTCDateTime" printMethod="com.mycompany.ims.utils.JaxbDateAdapter.printUTCDateTime" /&gt; &lt;/bindings&gt; &lt;/bindings&gt; &lt;bindings node="//xs:complexType[@name='ApplicationHeaderV01']"&gt; &lt;bindings node=".//xs:element[@name='CreDt']"&gt; &lt;javaType name="java.util.Date" parseMethod="com.mycompany.ims.utils.JaxbDateAdapter.parseUTCDateTime" printMethod="com.mycompany.ims.utils.JaxbDateAdapter.printUTCDateTime" /&gt; &lt;/bindings&gt; &lt;/bindings&gt; &lt;/bindings&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload