EL表达式内这样写
${adprice.adreportData-confirm.speconDate}
2个都是时间类型的,但是会报错,大家有什么好的解决办法么错误信息:   java.lang.IllegalArgumentException: Cannot convert 09-4-27 下午4:52 of type class java.sql.Timestamp to Number
   

解决方案 »

  1.   

    日期类型是不能直接相减的。
    最好把日期化成 Long类型的毫秒在去减
      

  2.   

      <body> <%   
        
      Date adreportData = (Date)request.getSession().getAttribute("adprice.adreportData");
           Date speconDate = (Date)request.getSession().getAttribute("confirm.speconDate");
         long l =adreportData.getTime()-speconDate.getTime();  
       out.println(l/1000+"秒");
     
      
       %>  </body>
      

  3.   


    <%  
        
      Date adreportData = (Date)request.getSession().getAttribute("adprice.adreportData"); 
          Date speconDate = (Date)request.getSession().getAttribute("confirm.speconDate"); 
        long l =adreportData.getTime()-speconDate.getTime();   
      out.println(l/1000+"秒");   
      %> 
      

  4.   


    Date adreportData = (Date)request.getSession().getAttribute("adprice.adreportData"); 
          Date speconDate = (Date)request.getSession().getAttribute("confirm.speconDate"); 
        long l =adreportData.getTime()-speconDate.getTime();   
      out.println(l/1000+"秒");