Hi,

I'm new to BeanUtils and I would firstly like to say a big thank you - this is 
such a useful utility and has saved me countless hours of my time!

I am, however, running into a difficulty. I am using BeanUtils 1.8.0 to copy a 
java.util.Date property from one bean to another. I have noticed that if the 
java.util.Date property is set to null, when I call BeanUtils.copyProperties() 
I get the following error:

Exception in thread "main" org.apache.commons.beanutils.ConversionException: No 
value specified for 'Date'
    at 
org.apache.commons.beanutils.converters.AbstractConverter.handleMissing(AbstractConverter.java:310)
    at 
org.apache.commons.beanutils.converters.AbstractConverter.convert(AbstractConverter.java:136)
    at 
org.apache.commons.beanutils.converters.ConverterFacade.convert(ConverterFacade.java:60)
    at 
org.apache.commons.beanutils.BeanUtilsBean.convert(BeanUtilsBean.java:1074)
    at 
org.apache.commons.beanutils.BeanUtilsBean.copyProperty(BeanUtilsBean.java:437)
    at 
org.apache.commons.beanutils.BeanUtilsBean.copyProperties(BeanUtilsBean.java:286)
    at org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:137)
    at Main.main(Main.java:10)


I have copied the sample code for the two beans and a test main class below. 
Could anybody else verify that this is occurring too? I am using 
beanutils-1.8.0.

Tom

-------------------------------------

import java.util.Date;

public class Bean1 {
    
    private Date date;

    public Bean1() {
        super();
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
    
}

-------------------------------------

import java.util.Date;

public class Bean2 {
    
    private Date date;

    public Bean2() {
        super();
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
    
}

-------------------------------------

import org.apache.commons.beanutils.BeanUtils;

public class Main {

    public static void main(String[] args) throws Exception {
        Bean1 bean1 = new Bean1();
        bean1.setDate(null);
        Bean2 bean2 = new Bean2();
        
        BeanUtils.copyProperties(bean2, bean1);
        
        System.out.println(bean2.getDate());
        
    }

}





_________________________________________________________________
Discover Bird's Eye View now with Multimap from Live Search
http://clk.atdmt.com/UKM/go/111354026/direct/01/

Reply via email to