I have a tag with the following:
<%@ tag body-content="empty"%>
<%@ attribute name="timestamp" required="true" type="java.sql.Timestamp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:useBean id="dateValue" class="java.util.Date" />
<c:if test="${not empty timestamp}">
<jsp:setProperty name="dateValue" property="time" value="${timestamp}" />
<span title="${timestamp}"> <fmt:formatDate value="${dateValue}"
pattern="MM/dd/yyyy HH:mm" /> </span>
</c:if>
I get the following error however:
Error 500: com.ibm.ws.jsp.JspCoreException: java.lang.IllegalArgumentException: Cannot convert 5/1/12 10:36 AM of type class java.sql.Timestamp to long
I was trying to follow this answer to convert a timestamp to a date in JSTL, so I wouldn't have change anything in my servlet. How can I convert a java.sql.Timestamp
to a date so that formatDate
can work with it, using JSTL?