如何在Spring MVC中显示日期和时间?

时间:2015-10-27 06:15:52

标签: java spring date spring-mvc datetime

这是我的pojo类方法:

@Column(name = "TH_EFFECTIVE_TIME")  
    private Date thEffectiveTime;

public Date getThEffectiveTime() {
    return thEffectiveTime;
}

public void setThEffectiveTime(Date thEffectiveTime) {
    this.thEffectiveTime = thEffectiveTime;
}

我的输出错误如下:

  

1445925903000

1 个答案:

答案 0 :(得分:0)

试试这个。 Temporal将转换您的时间戳。请记住将其保留为unix时间戳。你的是ms而不是秒。

@Temporal(TemporalType.DATE)
@Column(name = "TH_EFFECTIVE_TIME")  
private Date thEffectiveTime;

public Date getThEffectiveTime() {
    return thEffectiveTime;
}

public void setThEffectiveTime(Date thEffectiveTime) {
    this.thEffectiveTime = thEffectiveTime;
}