-
Nov 26th, 2004, 10:04 AM
#1
CustomEditor for java.sql.Date ?
I have a JSP that binds to a data bean.
In that data bean, I have a java.util.Date attribute and a java.sql.Date attribute.
My initBinder is as follows:
protected void initBinder (
HttpServletRequest request, ServletRequestDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, null, new
CustomDateEditor(dateFormat, true));
binder.registerCustomEditor(java.sql.Date.class, null, new
CustomDateEditor(dateFormat, true));
}
The java.util.Date attribute passes, but the java.sql.Date attribute doesn't, as I continually get:
Failed to convert property value of type [java.lang.String] to required type [java.sql.Date]
I looked up the CustomDateEditor and found this in the Spring docs on CustomDateEditor: it is a "PropertyEditor for java.util.Date".
Thus, my question is this. Does anyone know how to use initBinder on a field of type java.sql.Date?
Jim
-
Nov 29th, 2004, 10:28 AM
#2
in initBinder register the Date Editor, by default it is "off"
binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true));
change parameters accordingly...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules