On 3/16/06, Vladimir Coutinho <[EMAIL PROTECTED]> wrote:
> I tried to use convertDateTime (type="date") and a property java.sql.Date. I
> got conversion error. When I changed the bean property to java.util.Date the
> error was gone.
>
>  To user java.sql.Date I have to code a custimized converter?

Probably.

javax.faces.convert.DateTimeConverter uses DateFormat.parse() to
generate an object, and that object is a java.util.Date.

An easy solution would be to create a subclass of
javax.faces.convert.DateTimeConverter that overrode getAsObject() and
changed the java.util.Date to a java.sql.Date.


    public Object getAsObject(FacesContext facesContext, UIComponent
uiComponent, String value)
    {
        java.util.Date date = super.getAsObject(facesContext,
uiComponent, value);
        if (null == date)  return null;
        return convertJavaUtilDateToJavaSqlDate(date);
    }

I think you could then just register this as your global converter for
java.sql.Date types.


-Mike

Reply via email to