【问题标题】:How to display Date and Time in Spring MVC?如何在 Spring MVC 中显示日期和时间?
【发布时间】:2015-10-27 06:15:52
【问题描述】:

这是我的 pojo 类方法:

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

public Date getThEffectiveTime() {
    return thEffectiveTime;
}

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

我得到这样的错误输出:

1445925903000

【问题讨论】:

  • 你能再解释一下吗?您想在哪里显示日期和时间?或者您想存储当前日期和时间?你是怎么安排时间的?

标签: java spring date spring-mvc datetime


【解决方案1】:

试试这个。时间将转换您的时间戳。请记住将其保留为 Unix 时间戳。你的单位是毫秒而不是秒。

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

public Date getThEffectiveTime() {
    return thEffectiveTime;
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-02
    • 1970-01-01
    • 2019-04-24
    • 2018-09-05
    • 2013-07-13
    • 1970-01-01
    • 2018-02-28
    • 1970-01-01
    相关资源
    最近更新 更多