Background
I have a Root element class that contains a variable of the java.sql.Timestamp class, I want JAXB to create an xml element from this variable.
What i tried
- I am creating a class adapter that 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 that receives this 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.
I also checked this thread , but it talks about String for TimeStamp, but not in my case.
Any help would be appreciated.
EDIT
This variable is in the OrderStatus class, I call it the OrderImpl class as follows
@Override @XmlElement(name = "Status", type = OrderStatus.class) public OrderStatus getStatus() { return status; }
source share