页面时间输入框:

  
 
      
                 
       
                          

action中接收时间,根据时间查询:

public String findJftzdRizhi(){        resultMap = new HashMap();        if(jftzdRizhi!=null){            resultMap.put("caozuoShijian", jftzdRizhi.getCaozuoShijian());            if(jftzdRizhi.getCaozuoShijian()!=null){                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");                String begin = formatter.format(jftzdRizhi.getCaozuoShijian());                Calendar calendar = new GregorianCalendar();                 calendar.setTime(jftzdRizhi.getCaozuoShijian());                 calendar.add(calendar.DATE,1);  //把日期往后增加一天.整数往后推,负数往前移动                 Date date=calendar.getTime();   //这个时间就是日期往后推一天的结果                 String end = formatter.format(date);                resultMap.put("begin", begin);                resultMap.put("end", end);            }                   }        Page page = service.findJftzdRizhi(resultMap, getPage(), getRows());        if(page.getResults().size()!=0){            resultMap.put("total", page.getTotalSize());            resultMap.put("rows", page.getResults());        }else{            resultMap.put("total", 0);            resultMap.put("rows", 0);        }        return SUCCESS;    }

service中接受从action传过来的条件valuemap,用to_date()函数拼接在Hql语句中:

@Transactional(propagation=Propagation.REQUIRED)public Page findJftzdRizhi(Map valueMap,int curPage, int pageNum){   String hql = "from JftzdRizhi i where 1=1";   if(valueMap.get("caozuoShijian")!=null&&!"".equals(valueMap.get("caozuoShijian"))){      hql=hql+" and i.caozuoShijian       between TO_DATE('"+valueMap.get("begin")+"','yyyy-MM-dd')       and TO_DATE('"+ valueMap.get("end") +"','yyyy-MM-dd')";   }   return dao.find(hql, curPage, pageNum);}