我尝试使用 BeanUtills 将 Data(java.util.Date) 值从源复制到目标。它给出了日期到字符串的转换异常。
这种问题的解决方案是什么?
我的实现如下..
import java.util.Date;
public class Bean1 {
private Date date;
public Bean1() {
}
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() {
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
==================================================== =========
我的复制属性方法如下
public static void copyProperties(Object src, Object dest) throws llegalAccessException,InvocationTargetException, NoSuchMethodException {
Field[] attributes = dest.getClass().getDeclaredFields();
for (Field property : attributes) {
BeanUtils.setProperty(dest, property.getName(), BeanUtils.getProperty(
src, property.getName()));
}
}