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

onaled777Asked:
Who is Participating?
 
rrzCommented:
Please try this JSP.
<%@ page import="java.util.*" %>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
   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

0
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.