0

I'm making a website where customers can make reservations. Here I am going to save the reservation date to database. The date is saved in the database in "YYYY-MM-DD" format. (eg -: 2020-05-12)

The code in creating the column is startDate DATE

In my jsp page, I'm going to retrieve the reservation details as a list.

The code is as follows.

<core:forEach items="${pendingReservations}" var="reservation">
<tr>
<td>${reservation.startDate}</td>
</tr>

This code works perfectly fine except it shows the date in "YYYY-MM-DD HH:MM:SS" format. (eg -: 2020-05-12 00:00:00.0)

Here, I want to dispay the date in YYYY-MM-DD format. How can I do this?

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Akila Ranasinghe
  • 167
  • 1
  • 13

1 Answers1

0

add taglib

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

and try this

 <fmt:formatDate value=${reservation.startDate} pattern="yyyy-MM-dd"/>
Evgeniy
  • 146
  • 3
  • 12