On this occasion will teach you how to format long as date in JSP.
Recently happened to me that sent a field of type date data model using Spring and the render in view is displayed as long since it was used, so I had to investigate a little and not found much information.
<jsp:useBean id="dateValue" class="java.util.Date"></jsp:useBean>
<jsp:setProperty name="dateValue" property="time" value="${documento.fechaRecepcion}"></jsp:setProperty>
<b>Date of receipt:</b>
<fmt:formatDate type="time" value="${dateValue}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
If with the code not them was clear to first view the process is the following:
- Create a new bean of type date
- We provide value to this bean through the long value that return us our model
- We use the bean in a label format as we would if we received a date
I hope you will be useful this trick. Best regards!