String dzDate = "20200804"; // dzDate = "\uFEFF20200804"; SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");//注意月份是MM SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM Date dzDateObj = sdf1.parse(dzDate); String startDayTime = sdf2.format(dzDateObj)+" 00:00:00"; //2020-08-04 00:00:00 //加一天 Calendar cal = Calendar.getInstance(); cal.setTime(dzDateObj); cal.add(Calendar.DAY_OF_YEAR,1); Date addDate = cal.getTime(); String endDayTime = sdf2.format(addDate)+" 00:00:00";//2020-08-05 00:00:00 //查询指定字段 paySerialQueryWrapper.select("PAY_SERIAL_ID","PAY_CHANNEL_SERIAL","AMOUNT"); //查询条件为时间范围 paySerialQueryWrapper.apply("UNIX_TIMESTAMP(PAY_DATE) >= UNIX_TIMESTAMP(‘"+startDayTime+"‘)"); paySerialQueryWrapper.apply("UNIX_TIMESTAMP(PAY_DATE) < UNIX_TIMESTAMP(‘"+endDayTime+"‘)"); //查询当天所有支付记录 List<PaySerial> pcPaySerials = paySerialService.list(paySerialQueryWrapper);
mybatisplus查询时间范围+查询指定字段 java日期+1【我】
原文:https://www.cnblogs.com/libin6505/p/13433857.html