通过执行日期“yyyy-MM-dd”,格式来查询时分秒
String date1 = demandResponseListQuery.getTime(); Date date = new Date() ; try { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); date = dateFormat.parse(date1); } catch (ParseException e) { // 处理异常 e.printStackTrace(); }
if(!StringUtils.isEmpty(date)) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); // 设置开始时间为 2023-08-01 00:00:00 calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Date startTime = calendar.getTime(); // 设置结束时间为 2023-08-02 00:00:00 calendar.add(Calendar.DAY_OF_MONTH, 1); Date endTime = calendar.getTime(); wrapper.between("time",startTime,endTime); }