您的位置:首页 > 编程语言 > Java开发

how to solve "java.sql.Timestamp does not have a no-arg default constructor" ?

2012-10-19 15:55 686 查看
Step 1, create  TimestampAdapter  class
import java.sql.Timestamp;
import java.util.Date;
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());
}
}


Step 2, Attach the following code to every usage of the Timestamp class,such as:

@XmlJavaTypeAdapter(value=TimestampAdapter.class,type=Timestamp.class)
@Column(name = "ENDTIME", length = 7)
public Timestamp  getEndtime() {
return this.endtime;
}

public void setEndtime(Timestamp  endtime) {
this.endtime = endtime;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐