Reputation: 1117
Using jdk-1.7.0_51
and tomcat-7.0.42
on windows 7
platform my JSP page at:
<fmt:formatDate value='${abtest.modifiedDate}' pattern="yyyy-MM-dd HH:mm:ss"/>
where the abtest.modifiedDate
attribute is of type java.util.Date
and initialized with java.sql.Timestamp
instance.
throws the following exception:
javax.servlet.jsp.JspException: javax.el.ELException: Cannot convert 1/24/14 4:31 PM of type class java.sql.Timestamp to class org.joda.time.DateTime
The error seems to be strange because abtest.modifiedDate
attribute is not initialized with org.joda.time.DateTime
and it doesn't occur in all environments.
Have also tried to replace: <fmt:formatDate...
with <joda:format ...
tag but got another error:
javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: value attribute of format tag must be a ReadableInstant or ReadablePartial, was: java.sql.Timestamp
Upvotes: 0
Views: 2226
Reputation: 5264
Add this annotation on your DateTime
field in your entity class
@Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime birthDay;
And in your JSP
, keep using the joda format tag
:
<c:set var="formattedDateTimeValue">
<joda:format value="${DateTimeValue}" pattern="dd.MM.yyyy" />
<!-- Or any pattern you want -->
</c:set>
Upvotes: 1