转自:https://www.cnblogs.com/linjiqin/archive/2011/07/21/2112628.html

当用到了java.sql.Date时间等非内置对象时,如果对象为null则会出现此异常。最简单的方法就是保证非内置对象不为null。

在项目业务中随着需求的变化而变化,并不能保证内置对象都不为null,因此有必要对此异常进行解决,以达到通用的效果,以下为此异常的解决办法

      /** 上市时间 */
  private java.sql.Date timeToMarket;
    // 当属性timeToMarket为null时会抛出org.apache.commons.beanutils.ConversionException: No value specified异常
// public Date getTimeToMarket() {
// return timeToMarket;
// }
//
// public void setTimeToMarket(Date timeToMarket) {
// this.timeToMarket = timeToMarket;
// }

    //解决办法
public String getTimeToMarket() {
if (timeToMarket == null) return null;
DateFormat dateFormat = DateFormat.getDateInstance();
return dateFormat.format(this.timeToMarket);
} public void setTimeToMarket(String timeToMarket) {
if (timeToMarket == null || "".equals(timeToMarket.trim())) {
this.timeToMarket = null;
} else {
try {
DateFormat dateFormat = DateFormat.getDateInstance();
this.timeToMarket = new java.sql.Date(dateFormat.parse(
timeToMarket).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
}

org.apache.commons.beanutils.ConversionException: No value specified解决办法的更多相关文章

  1. org/apache/commons/pool/impl/GenericObjectPool异常的解决办法

    org/apache/commons/pool/impl/GenericObjectPool异常的解决办法 webwork+spring+hibernate框架的集成, 一启动Tomcat服务器就出了 ...

  2. org.springframework.beans.BeanUtils与org.apache.commons.beanutils.BeanUtils的copyProperties用法区别

    知识点 org.springframework.beans.BeanUtils与org.apache.commons.beanutils.BeanUtils都提供了copyProperties方法,作 ...

  3. Apache Commons BeanUtils

    http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.2/apidocs/org/apache/commons/beanut ...

  4. myeclipse的项目导入到eclipse下,com.sun.org.apache.commons.beanutils.BeanUtils不能导入

    com.sun.org.apache.commons.beanutils.BeanUtils这个包不能引入了怎么办自己下了个org.apache.commons的jar包了之后,改成import or ...

  5. 关闭log4j 输出 DEBUG org.apache.commons.beanutils.*

    2016-03-23 10:52:26,860 DEBUG org.apache.commons.beanutils.MethodUtils - Matching name=getEPort on c ...

  6. Apache Commons Beanutils对象属性批量复制(pseudo-singleton)

    Apache Commons Beanutils为开源软件,可在Apache官网http://commons.apache.org/proper/commons-beanutils/download_ ...

  7. org.apache.commons.beanutils.BeanMap简单使用例子

    一.org.apache.commons.beanutils.BeanMap; 将一个java bean允许通过map的api进行调用, 几个支持的操作接口: Object get(Object ke ...

  8. 对于Java Bean的类型转换问题()使用 org.apache.commons.beanutils.ConvertUtils)

    在进行与数据库的交互过程中,由数据库查询到的数据放在 map 中,由 map 到 JavaBean 的过程中可以使用 BeanUtils.populate(map,bean)来进行转换 这里要处理的问 ...

  9. Apache Commons Beanutils 三 (BeanUtils、ConvertUtils、CollectionUtils...)

    前言 前面已经学习了Apache Commons Beanutils包里的PropertyUtils和动态bean,接下来将学习剩下的几个工具类,个人觉得还是非常实用的,特别是CollectionUt ...

随机推荐

  1. openstack错误问题定位及调试

  2. python初级(302) 3 easygui简单使用二

    一.复习 1.easygui 信息提示对话框 2.easygui 是否对话框 二.easygui其它组件 1.选择对话框:choicebox(msg, title, choices) import e ...

  3. webpack实现跨域

    在devServer字段下配置proxy. // 本地开发 Server 配置 const DEV_SERVER_CONFIG = { historyApiFallback: true, hot: t ...

  4. [LeetCode] 133. Clone Graph 克隆无向图

    Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's ...

  5. [LeetCode] 274. H-Index H指数

    Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...

  6. kubernetes-subpath用法(把文件挂载在已存在的目录下,不覆盖原目录)

    以ngxin的配置文件为例子: nginx-deployment.yaml : apiVersion: v1 kind: ConfigMap metadata: name: nginx-cm data ...

  7. vs2019 中文离线安装包下载

    1. 通过在https://visualstudio.microsoft.com/zh-hans/downloads/ 下载VS2019, 之后会下载vs_enterprise__78682482.1 ...

  8. php HTTP协议

    HTTP协议 超文本传输协议(HTTP,HyperText Transfer Protocol) 最常见B/s架构中,使用,浏览器端与服务器端数据交互协议. 协议:约定好的一套语法规则. 规定:请求数 ...

  9. oracle11g数据库导入导出方法教程

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/xinxiaoyonng/article/ ...

  10. Spring Boot取消默认tomcat启动,打成war包发布到服务器运行

    一.设置打包方式 在pom.xml中设置打包格式 <packaging>war</packaging> 二.取消Spring Boot的tomcat <!--部署成war ...