beanutils.copyproperties里面的bigdecimal类型怎么处理
发布网友
发布时间:2022-05-24 00:06
我来回答
共1个回答
热心网友
时间:2023-11-12 16:53
[java] view plain copy print?
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.log4j.Logger;
/**
* @Title 扩展BeanUtils.copyProperties支持data类型
* @Description
* @author wangzs
* @date 2017-1-5
*/
public class BeanUtilsEx extends BeanUtils {
private static Logger logger = Logger.getLogger(BeanUtilsEx.class);
static {
ConvertUtils.register(new DateConvert(), java.util.Date.class);
ConvertUtils.register(new DateConvert(), String.class);
}
public static void copyProperties(Object target, Object source) {
// 支持对日期copy
try {
org.apache.commons.beanutils.BeanUtils.copyProperties(target, source);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.error("扩展BeanUtils.copyProperties支持data类型:" + e.getMessage());
e.printStackTrace();
}
}
}