Converting from long to Date in a jsp for fmt:formateDate

For the code snippet below the value note.referencedOn comes back as a long.

fmt:formatDate is expecting a Date so it throws an error.

How do i modify to get rid of that error.

<td><fmt:formatDate value="${note.referencedOn}" pattern="MM-dd-yyyy"/></td>

Open in new window

Who is Participating?
Please try this JSP.
<%@ page import="java.util.*" %>
<%@ taglib prefix = "c" uri = "" %>
<%@ taglib prefix="fmt" uri="" %>

   Date date = new Date();
   long d = date.getTime();
<c:set var="tomorrow" value="<%=new Date(d + 1000*60*60*24)%>" />
Tomorrow is <fmt:formatDate value="${tomorrow}" pattern="MM-dd-yyyy" />

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.