DateConverter does not support default String to 'Date' conversion.的处理
来源:互联网 发布:mac地址有什么用 编辑:程序博客网 时间:2024/05/18 01:09
DateConverter does not support default String to 'Date' conversion.的处理
在使用beanutils工具类封装javabean时,beanUtils不提供直接将字符串转换成Date(java.util.Date)数据类型的方法,
所以会出现下面警告:
或者类似下面异常:
org.apache.commons.beanutils.ConversionException: DateConverter does not support default String to 'Date' conversion.
解决办法:
1.自己写个转换器的代码块
try {ConvertUtils.register(new Converter() {//注册一个日期转换器public Object convert(Class type, Object value) {Date date1 =null; if(value instanceof String){ String date = (String) value;SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try {date1 = sdf.parse(date);} catch (ParseException e) {e.printStackTrace(); } } return date1; }}, Date.class);
2.哈哈!beanutil这个工具类源码里有提供DateLocaleConverter
这个类做注册的转化器
ConvertUtils.register(new DateLocaleConverter(), Date.class);
现实工具类方法为:
阅读全文
0 0
- DateConverter does not support default String to 'Date' conversion.的处理
- DateConverter does not support default String to 'Date' conversion解决办法
- DateConverter does not support default String to 'Date' conversion.
- DateConverter does not support default String to ‘Date’ conversion.
- DateConverter does not support default String to ‘Date’ conversion.
- DateConverter does not support default String to 'Date' conversion
- org.apache.commons.beanutils.ConversionException: DateConverter does not support default String to '
- 是用BeanUtils做工程出错org.apache.commons.beanutils.ConversionException: DateConverter does not support def
- GCC Warning ISO C++11 Does not allow conversion from literal string to char*
- Warning: ISO C++11 does not allow conversion from string literal to 'char*'
- warning: ISO C++11 does not allow conversion from string literal to 'char *'
- 出现Note: C++ does not support default-int这样的提示
- Note: C++ does not support default-int 问题
- 关于conversion from string to type date is not valid错误
- Norton Antivirus 2005 does not support to Repair feature的错误解决
- 绑定到异步的ObservableCollection [This type of CollectionView does not support changes to its SourceColl]
- This parser does not support specification "null" version "null" 问题的处理 .
- This parser does not support specification "null" version "null" 有关问题的处理
- Solr admin管理员界面介绍
- Mysql主从复制配置操作指导(主备)
- 一个不需要cookie与js却能实现类似cookie功能的手段
- 设计模式(Design Pattern)
- ElasticSearch 学习随笔
- DateConverter does not support default String to 'Date' conversion.的处理
- 程序员面试金典8.1
- View的圆角 IOS
- 反射-通过反射获取无参无返回值成员方法、带参带返回值成员方法并使用
- 常用字符串方法
- Android 中关于 【Cursor】 类的介绍
- TCP Split Handshake Attack
- java项目中想获取当前项目的路径
- 设计模式(一)----工厂模式