ava.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 或者是其它的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值