//计算剩余时间
private ActionForward showRemainTime(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
String startTime=session.getAttribute("startTime").toString();
long a=Long.parseLong(startTime);
long b=new java.util.Date().getTime();
long r=20*60000-(b-a-1000);
int h=(int)Math.abs(r/3600000);
String hour=chStr.formatNO(h,2);
int m=(int)(r)%3600000/60000;
String minute=chStr.formatNO(m,2);
int s=(int)((r)%3600000)%60000/1000;
String second=chStr.formatNO(s,2);
String time=hour+":"+minute+":"+second;
request.setAttribute("showRemainTime",time);
return mapping.findForward("showRemainTime");上面是正确的下面这句错误了请大侠们帮帮忙!
session.setAttribute("startTime",new java.util.Date().getTime());