【转载】Apache 的BeanUtils对象拷贝日期转换问题
来源:互联网 发布:js for 循环 异步函数 编辑:程序博客网 时间:2024/06/06 17:16
在Java对象的拷贝过程中,Apache的BeanUtils对日期的支持不是很好,但有扩展,大家可以找到它的日期转换器,注册进去就ok了
创建BeanUtils的子类,把日期转换器注册进去,以后用这个子类来copy对象:
public class BeanUtilEx extends BeanUtils {
private BeanUtilEx() {
}
static {
// 注册sql.date的转换器,即允许BeanUtils.copyProperties时的源目标的sql类型的值允许为空
ConvertUtils.register(new org.apache.commons.beanutils.converters.SqlDateConverter(null), java.sql.Date.class);
ConvertUtils.register(new org.apache.commons.beanutils.converters.SqlDateConverter(null), java.util.Date.class);
ConvertUtils.register(new org.apache.commons.beanutils.converters.SqlTimestampConverter(null), java.sql.Timestamp.class);
}
public static void copyProperties(Object target, Object source)
throws InvocationTargetException, IllegalAccessException {
// 支持对日期copy
org.apache.commons.beanutils.BeanUtils.copyProperties(target, source);
}
}
- 【转载】Apache 的BeanUtils对象拷贝日期转换问题
- Apache 的BeanUtils 拷贝日期对象转换问题
- BeanUtils进行日期格式的拷贝转换
- org.apache.commons.beanutils.BeanUtils 拷贝属性为对象的属性,拷贝地址
- BeanUtils.copyProperties() 拷贝对象属性时,日期为空的处理
- 慎用BeanUtils的对象拷贝方法
- BeanUtils拷贝两个对象的相同属性
- BeanUtils拷贝问题整理
- BeanUtils 工具 copyProperties 拷贝对象
- BeanUtils的拷贝功能
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- 类似BeanUtils.copyProperties拷贝对象属性值的方法
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- https://github.com/pkelsey/libuinet
- STM32 IAP程序跳转前后的中断问题
- iOS面试题(二)
- torch学习笔记<一>
- 约瑟夫环问题
- 【转载】Apache 的BeanUtils对象拷贝日期转换问题
- Maven学习总结(一)——Maven入门
- 解决Android 5.0以上Button自带阴影的问题
- 第十五周项目:范型程序
- 浅谈 PopupWindow 在 Android 开发中的使用
- iOS面试题(三)
- Android开发中Handler的案例分析
- Mongodb与Redis应用指标对比
- python dom解析xml 总结