Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, -1); // 设置日期为当前日期 calendar.setTime(calendar.getTime()); // 将日期设置为该月的第一天 calendar.set(Calendar.DAY_OF_MONTH, 1); // 获取本月的开始时间 Date startTime = calendar.getTime(); // 将日期设置为该月的最后一天 calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); // 获取本月的结束时间 Date endTime = calendar.getTime(); SimpleDateFormat simpleEndTime = new SimpleDateFormat("yyyy-MM-dd 23:59:59"); SimpleDateFormat simpleStartTime = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); SimpleDateFormat formatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date endDate = formatTime.parse(simpleEndTime.format(endTime)); Date startDate = formatTime.parse(simpleStartTime.format(startTime));