commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: BeanUtils copyProperties with null Date
Date Fri, 03 Oct 2008 19:32:22 GMT

--- Hanson Char <hanson.char@gmail.com> wrote:

> Or as a comparison, you can achieve the copying via
> BeanPopulator of
> beanlib, and it would just work.  See sample code
> below.
> 
>  
>
http://sourceforge.net/project/showfiles.php?group_id=140152
> 
> Cheers,
> Hanson
> 
> import java.util.Date;
> 
> import net.sf.beanlib.provider.BeanPopulator;
> 
> public class Bean1Bean2Main {
>     public static void main(String...args) {
>         Bean1 b1 = new Bean1();
>         Bean2 b2 = new Bean2();
> 
>         BeanPopulator.newBeanPopulator(b1,
> b2).populate();
>         System.out.println(b1.getDate());
>         System.out.println(b2.getDate());
> 
>         b1.setDate(new Date());
>         BeanPopulator.newBeanPopulator(b1,
> b2).populate();
>         System.out.println(b1.getDate());
>         System.out.println(b2.getDate());
>     }
> }
> 

FWIW, the simplest approach to this in Morph
(http://morph.sourceforge.net) should be:

Morph.copy(b2, b1);

-Matt

>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@commons.apache.org
> For additional commands, e-mail:
> user-help@commons.apache.org
> 
> 



      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message