try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date startDate = sdf.parse("2023-07-05"); Date endDate = sdf.parse("2023-07-11"); Date existingStartDate = sdf.parse("2023-07-12"); Date existingEndDate = sdf.parse("2023-07-12"); if (startDate.compareTo(existingEndDate) <= 0 && endDate.compareTo(existingStartDate) >= 0) { System.out.println("日期重叠!"); } else { System.out.println("日期不重复!"); } }catch (Exception e){ e.getMessage(); }
判断日期区间不允许重复传入
于 2023-07-17 17:10:11 首次发布