jstl fmt:formatDate – 小时/分钟/秒不显示

huangapple go评论55阅读模式
英文:

jstl fmt:formatDate - hours/minutes/seconds dont'appear

问题

我使用JDBC Template从Postgres中提取日期,并在Spring MVC中使用JSTL和JSP在视图中显示它们。

日期存储在Postgres数据库中的格式为"Timestamp with timezone"。
我从数据库中读取的示例值是:2020-07-29 10:20:55.423+02

当我尝试在JSP中显示它时,使用以下指令:

<fmt:formatDate	value="${bean.date}" pattern="dd-MM-yyyy HH:mm:ss" />

然后在前端显示的是:

29-07-2020 00:00:00

后端bean的类型是java.util.Date,我不应该更改它。
问题是什么?

英文:

I'm fetching date using JDBC Template from Postgres and showing them on the view in spring MVC using jstl and jsp.

Date is stored in Postgres database in format "Timestamp with timezone"
Example value read from database by myself: 2020-07-29 10:20:55.423+02

When I'm trying to show in in JSP using following instruction:

&lt;fmt:formatDate	value=&quot;${bean.date}&quot; pattern=&quot;dd-MM-yyyy HH:mm:ss&quot; /&gt;

Then it shows on the front

29-07-2020 00:00:00

Backing bean is type java.util.Date and i shouldn't change it.
What is the problem ?

答案1

得分: 0

当您通过JDBC获取数据时,应使用getTimestamp(String columnLabel),它应该返回带有时间的数据。

参见ResultSet.getTimeStamp()

英文:

When you are fetching the data via JDBC you should use getTimestamp(String columnLabel) that should return it with time.

See ResultSet.getTimeStamp()

huangapple
  • 本文由 发表于 2020年7月29日 18:11:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63151260.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定