Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well following solution template above</p> <p>1.) Create an XSML Adapter</p> <pre><code>import java.util.Date; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.adapters.XmlAdapter; import org.joda.time.DateTime; @XmlTransient public class XSDDateTimeMarshaller extends XmlAdapter&lt;Date, DateTime&gt; { @Override public DateTime unmarshal(Date date) throws Exception { return new DateTime(date.getTime()); } @Override public Date marshal(DateTime dateTime) throws Exception { return new Date(dateTime.getMillis()); } } </code></pre> <p>2.) Annotate jodatime attribute with (snipet from an entity class):</p> <pre><code>... @XmlRootElement(name="MyEntity", namespace="http://www.mycompany.com/module") @XmlAccessorType(XmlAccessType.FIELD) @XmlType(propOrder={"...", "...", "timeStamp", "...", "..."}) public class MyEntity ... @XmlElement(namespace="http://www.mysite.com/module") @XmlJavaTypeAdapter(XSDDateTimeMarshaller.class) @NotNull @Type(type="org.joda.time.contrib.hibernate.PersistentDateTime") @Column(name="TIME_STAMP") private DateTime timeStamp; ... } </code></pre> <p>3.) add type bindings to your myentity.xsd</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd" targetNamespace="http://www.mysite.com/module" xmlns:tns="http://www.mysite.com/module" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1"&gt; &lt;xsd:annotation&gt; &lt;xsd:appinfo&gt; &lt;jaxb:globalBindings&gt; &lt;jaxb:javaType name="org.joda.time.DateTime" xmlType="xsd:dateTime" parseMethod="com.mycompany.myproduct.marshaller.XSDDateTimeMarshaller.unmarshal" printMethod="com.mycompany.myproduct.marshaller.XSDDateTimeMarshaller.marshal"/&gt; &lt;jaxb:javaType name="org.joda.time.DateTime" xmlType="tns:date" parseMethod="com.mycompany.myproduct.marshaller.XSDDateTimeMarshaller.unmarshal" printMethod="com.mycompany.myproduct.marshaller.XSDDateTimeMarshaller.marshal"/&gt; &lt;/jaxb:globalBindings&gt; &lt;/xsd:appinfo&gt; &lt;/xsd:annotation&gt; &lt;xsd:element name="MyEntity" type="tns:MyEntity"/&gt; &lt;xsd:complexType name="MyEntity"&gt; &lt;xsd:sequence&gt; ... &lt;xsd:element name="timeStamp" type="tns:date"/&gt; .... &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;xsd:simpleType name="date"&gt; &lt;xsd:restriction base="xsd:dateTime" /&gt; &lt;/xsd:simpleType&gt; &lt;/xsd:schema&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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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