Temporal

来源:互联网 发布:好看的水杯知乎 编辑:程序博客网 时间:2024/05/18 06:23

1.日期类型,实例:

private Date birthday;

@Temporal(TemporalType.DATE)
 public Date getBirthday() {
  return birthday;
 }

public void setBirthday(Date birthday) {
  this.birthday = birthday;
 }

数据库对应字段类型为:date型 

2.时间类型,实例:
private Date getUpdateTime;
 
@Temporal(TemporalType.TIME)
 public Date getGetUpdateTime() {
  return getUpdateTime;
 }
 public void setGetUpdateTime(Date getUpdateTime) {
  this.getUpdateTime = getUpdateTime;
 }
 

数据库对应字段类型为:time型 

3.日期时间类型,实例:
 private Date toDay;
 
@Temporal(TemporalType.TIMESTAMP)
 public Date getToDay() {
  return toDay;
 }
 public void setToDay(Date toDay) {
  this.toDay = toDay;
 }
 

数据库对应字段类型为:datetime型