How to show date using c: out tag in some format

I am using JSTL. I want to show the date in JSP using the <c:out ..> .

I tried <c:out value = "<fmt:formatdate value = '${datevar}'"/> .

But it displays as <fmt:formatdate value = '${datevar}' in HTML.

What needs to be changed to display the date with the expected format?

+7
source share
1 answer

You do not need <c:out> , and the tag is actually called <fmt:formatDate> (note the uppercase D ).

 <fmt:formatDate value="${datevar}" pattern="MM/yyyy" /> 

If you really want to save it in some variable to redisplay later in <c:out> , use the var attribute.

 <fmt:formatDate value="${datevar}" pattern="MM/yyyy" var="newdatevar" /> ... <c:out value="${newdatevar}" /> 
+19
source

All Articles