oracel时间字段

**

private Date cjsj; //数据库中字段是timestamp(6)

@Temporal(TemporalType.DATE)
@Column(name = "CJSJ")
public Date getCjsj() {
return this.cjsj;
}

public void setCjsj(Date cjsj) {
this.cjsj = cjsj;
}

 

private String time;

//创建时间
if(time!=null&&!"".equals(time)){
hql.append(" and to_char(cjsj,'yyyy-MM-dd') =:cjsj ");
params.put("cjsj", time);
}

下面这种用to_date()

if(model.getDdrq()!=null&&!"".equals(model.getDdrq().trim())){
hql.append(" and to_date(ddrq,'yyyy-MM-dd') =to_date(:ddrq,'yyyy-MM-dd')");
params.put("ddrq", model.getDdrq().trim());
}

数据库中字段是varchar2(100)

 

**

posted @ 2014-12-24 16:19  野鹤闲人  阅读(232)  评论(0编辑  收藏  举报