Search code examples
javaspring-mvcjdbcjstl

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


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:

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

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 ?


Solution

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

    See ResultSet.getTimeStamp()