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