- //开始时间
- if (!StringUtils.isEmpty(VO.getStarttime())) {//判断非空才可以往下走
- sql.append(" and 时间字段 >= to_date( ?, 'yyyy-mm-dd hh24:mi:ss') ");
- if (VO.getStarttime().length() == 19) {//19位就是年月日 时分秒
- listparm.add(VO.getStarttime());//直接添加就ok了
- } else if (VO.getStarttime().length() == 10) {//10位就只有年月日,但是要满足上面日期格式,所以要加上00:00:00
- listparm.add(VO.getStarttime().trim() + " 00:00:00");
- }
- }
- //结束时间
- if (!StringUtils.isEmpty(VO.getEndtime())) {
- sql.append(" and 时间字段 <= to_date( ?, 'yyyy-mm-dd hh24:mi:ss') ");
- if (VO.getEndtime().length() == 19) {
- listparm.add(VO.getEndtime());
- } else if (VO.getEndtime().length() == 10) {
- listparm.add(VO.getEndtime().trim() + " 23:59:59");
- }
- }
- 时间范围是00:00:00---23:59:59(零点到十二点)
查询时间的条件判断sql.append()拼接,list.add(值)
最新推荐文章于 2023-03-23 10:46:18 发布