I have a loop that goes through all the news items we have on our site. One of the fields is date ${newsitem.value['Date']}, given in millliseconds. I’d like to display this date in month/day/year format on the webpage. I thought JSTL format tag, <fmt:formatDate>, would help, but I haven’t succeeded. Do you know how to do it?
<cms:contentaccess var="newsitem" />
<h2><c:out value="${newsitem.value['Title']}" /></h2>
// display date here
<c:out value="${newsitem.value['Text']}" escapeXml="false" />
Yes the JSTL
formatDatetag should do the job in combination with changing the Timestamp value into a date object (which is required to work around the exception mentioned in your comment).Ensure that you have properly defined the
fmtprefix in the JSP declarationsRender the output, convert the time stamp to a date value first. I’m using
yyyy-MM-ddas the format pattern, thedateFormattag supports other formatting options as well.