将hibernate里的日期数据存入SQL server数据库怎么转换啊?
private Date levaeTime;
public Date getLevaeTime() {
return this.levaeTime;
}
public void setLevaeTime(Date levaeTime) {
this.levaeTime = levaeTime;
}
Elestron els=new Elestron();
els.setLevaeTime("2008-10-25");
这行一直报错应该怎么解决啊。
------解决方案--------------------
Java code
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = sdf.parse("2008-10-25");
els.setLevaeTime(date);
}
catch (ParseException e) {
e.printStackTrace();
}