Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

fmt:formatDate with incoming parameter

616326Aug 20 2008 — edited Jul 9 2009
I have a bean that has a set method that takes in a java.sql.Date object.
public void setStartDate(java.sql.Date newValue){
	startDate= newValue;
}
This is used in a PreparedStatement to retrieve data from the database.

I am pulling the value from the URL. For example, the url would be:
http://localhost:8080/test/somePage.jsp?startDate=01-APR-2008
Now, in the JSP I am trying to use the fmt:formatDate tag.
<fmt:formatDate value="${param.startDate}" var="startDate" pattern="yyyy-mm-dd"/>
However, I just cannot get it to work. It keeps throwing errors like:
Attempt to convert String "01-Apr-2008" to type "java.util.Date", but there is no PropertyEditor for that type

So after some reading, I decided to try fmt:parseDate. So I then did:
<fmt:parseDate var="startDate" value="${param.startDate}" pattern="yyyy-mm-dd" />
Then I get the error:
In <parseDate>, value attribute can not be parsed: "01-Apr-2008"

All I am trying to do is call:
<jsp:setProperty property="startDate" name="HomeBean" value="${startDate}"/>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2009
Added on Aug 20 2008
13 comments
1,160 views