`
javasss
  • 浏览: 66975 次
  • 性别: Icon_minigender_1
  • 来自: 河南
社区版块
存档分类
最新评论

java.lang.IllegalArgumentException: Cannot format given Object as a Date

 
阅读更多
【异常报错提示】:
org.apache.jasper.JasperException: Cannot format given Object as a Date
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause

java.lang.IllegalArgumentException: Cannot format given Object as a Date
java.text.DateFormat.format(Unknown Source)
java.text.Format.format(Unknown Source)
com.lyang.governmentbill.CCI.jsp.Bean.ReportManagerBean.reportManagerBean(ReportManagerBean.java:115)
org.apache.jsp.reportList_jsp._jspService(reportList_jsp.java:141)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
【异常处理】
Apache Tomcat/5.5.17
ReportManagerBean.java:115行代码如下:

String begin=sdf.format(begintime);

注:sdf为:SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");

    begintime 为:String begintime=request.getParameter("begintime");

传值是对象不是日期类型 将begintime 转化一下

String begin=sdf.format(begintime); 改为:String begin=sdf.format(DateFormat.getDateInstance().parse(begintime)); 就好了。SimpleDateFormat 的format方法是:public final java.lang.String format(java.util,Date org0); format方法应该传一个Date类型的参数,而不是String 或者是其它的。

分享到:
评论
1 楼 夜曲6763 2015-09-25  
谢谢LZ,解决了我的问题

相关推荐

Global site tag (gtag.js) - Google Analytics