title: Jersey how to annotate java.sql.Timestamp object
body: <p><strong>Background</strong></p>
  
  <p>I have a Root element class which contains variable of the class <code>java.sql.Timestamp</code>, I want JAXB to create xml element from that variable.</p>
  
  <p><strong>What I have tried</strong></p>
  
  <ul>
  <li>I create class adapter which is.</li>
  </ul>
  
  <blockquote>
    <p>import java.sql.Date;</p>
    
    <p>import java.sql.Timestamp;</p>
    
    <p>import javax.xml.bind.annotation.adapters.XmlAdapter;</p>
  </blockquote>
  
  <pre><code>public class TimestampAdapter extends XmlAdapter &lt;Date, Timestamp&gt; {
  </code></pre>
  
  <blockquote>
  <pre><code>  public Date marshal(Timestamp v) {
        return new Date(v.getTime());
    }
  
    public Timestamp unmarshal(Date v) {
        return new Timestamp(v.getTime());
    }
  </code></pre>
    
    <p>}</p>
  </blockquote>
  
  <ul>
  <li>. Then I annotate the function which gets that variable:</li>
  </ul>
  
  <blockquote>
    <p>@XmlJavaTypeAdapter(TimestampAdapter.class)<br>
    public java.sql.Timestamp getEndDate() {  </p>
    
    <p>if (endDate == null)           </p>
    
    <p>retrieveInfo();        </p>
    
    <p>return endDate;    </p>
  </blockquote>
  
  <p>}</p>
  
  <blockquote>
    <p><strong>Problem</strong></p>
  </blockquote>
  
  <p>I still get this exception</p>
  
  <pre><code>java.sql.Date does not have a no-arg default constructor.
  </code></pre>
  
  <p>Also I have checked <a href="https://stackoverflow.com/questions/2519432/jaxb-unmarshal-timestamp">This Thread</a>, but it is talking about String to TimeStamp, not my case.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This variable is in the class <code>OrderStatus</code>, I call it from class <code>OrderImpl</code> like this</p>
  
  <pre><code>@Override
      @XmlElement(name = "Status", type = OrderStatus.class)
      public OrderStatus getStatus() {
          return status;
      }
  </code></pre>