jimdier
Nov 26th, 2004, 11:04 AM
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
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