Of course, right after I sent the email, I figured out my problem.  I
created the following class, then registered it in my ContextListener using
this line:

ConvertUtils.register(new SqlDateConverter(), java.sql.Date.class);




package com.caris.pmis.util;
import java.sql.Date;
import org.apache.commons.beanutils.Converter;
import org.apache.commons.beanutils.converters.*;

public class SqlDateConverter implements Converter
{
  private org.apache.commons.beanutils.converters.SqlDateConverter
sqlDateConverter = new
org.apache.commons.beanutils.converters.SqlDateConverter();


  public Object convert(Class type, Object value)
  {
    if(value == null || value.toString().length() < 1)
      return null;

    return sqlDateConverter.convert(type, value);
  }
}



Cheers,
Graham


-----Original Message-----
From: Graham Lounder [mailto:[EMAIL PROTECTED]
Sent: January 19, 2004 3:30 PM
To: [EMAIL PROTECTED]
Subject: BeanUtils Date Converter


Hey all,

I know this question has been addressed numerous times but I can't seem to
find the answer.

I'm trying to convert strings in my forms to java.sql.Date in my dto.  Its
throwing a conversion error when my form value is null or blank.  Is there a
way to get nulls or passed through the BeanUtils.copyProperties function?  I
read that I may be able to create my own converters too.  Is there any
documentation on this?

Cheers,
Graham

Graham Lounder - Java Developer
Spatial Components Division
CARIS www.caris.com
Tel: +1-506-458-8533 Fax: +1-506-459-3849
CARIS has expanded to new office facilities. Our new mailing address is:
115 Waggoners Lane, Fredericton, New Brunswick, E3B 2L4, Canada.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to