java.text.SimpleDateFormat format=new java.text.SimpleDateFormat("yyyy-MM-dd");
Date startPdate;
String strStartPdate = request.getParameter("startpdate");
if( strStartPdate == null || strStartPdate.trim().equals("")){
startPdate = null ;
}else{
startPdate = format.parse(request.getParameter("startpdate"));
}
做了空值判断后,为什么给startpdate传入空值后,后台报异常为:
严重: Servlet.service() for servlet jsp threw exception
java.text.ParseException: Unparseable date: "null"
Date startPdate;
String strStartPdate = request.getParameter("startpdate");
if( strStartPdate == null || strStartPdate.trim().equals("")){
startPdate = null ;
}else{
startPdate = format.parse(request.getParameter("startpdate"));
}
做了空值判断后,为什么给startpdate传入空值后,后台报异常为:
严重: Servlet.service() for servlet jsp threw exception
java.text.ParseException: Unparseable date: "null"
"null" 是一个字符串很明显,你的startpdate参数是 "null"
他可转化不了成数字的
String是null时, 返回的就是字符串null
非常感谢。