commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hanson Char" <hanson.c...@gmail.com>
Subject Re: BeanUtils copyProperties with null Date
Date Fri, 03 Oct 2008 19:18:37 GMT
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());
    }
}

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


Mime
View raw message