I am using JSTL. I want to display a date in JSP using <c:out ..>
tag.
I tried <c:out value = "<fmt:formatdate value = '${datevar}'"/>
.
But it displays as <fmt:formatdate value = '${datevar}'
in the HTML.
What needs to be changed to display date with expected format?
You don't need <c:out>
and the tag is actually called <fmt:formatDate>
(note the uppercase D
).
<fmt:formatDate value="${datevar}" pattern="MM/yyyy" />
If you actually want to store it in some variable to redisplay later in <c:out>
, then use var
attribute.
<fmt:formatDate value="${datevar}" pattern="MM/yyyy" var="newdatevar" />
...
<c:out value="${newdatevar}" />