//一个时间区间,判断另一个区间是否嵌套
private boolean getErrSituation(Map<Integer, Map<String, Object>> mapAll) throws ParseException {
SimpleDateFormat SDF_HM = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Map<Integer, Map<String, Object>> mapAllCopy = mapAll;
for (Integer map : mapAll.keySet()) {
for (Integer mapCopy : mapAllCopy.keySet()) {
String allS = (String) mapAll.get(map).get("startdate");
String allE = (String) mapAll.get(map).get("enddate");
String copyS = (String) mapAllCopy.get(mapCopy).get("startdate");
String copyE = (String) mapAllCopy.get(mapCopy).get("enddate");
//etid为表id,itemno为唯一键
if (mapAllCopy.get(mapCopy).get("etid").equals(mapAll.get(map).get("etid")) &&
!mapAllCopy.get(mapCopy).get("itemno").equals(mapAll.get(map).get("itemno"))) {
if (copyS.equals(allS) && copyE.equals(allE)) {
return true;
} else if ((SDF_HM.parse(copyS).compareTo(SDF_HM.parse(allS)) <= 0 && SDF_HM.parse(copyE).compareTo(SDF_HM.parse(allS)) >= 0) ||
(SDF_HM.parse(copyS).compareTo(SDF_HM.parse(allE)) <= 0 && SDF_HM.parse(copyE).compareTo(SDF_HM.parse(allE)) >= 0) ||
(SDF_HM.parse(copyS).compareTo(SDF_HM.parse(allS)) > 0 && SDF_HM.parse(copyE).compareTo(SDF_HM.parse(allE)) < 0)) {
return true;
}
}
}
}
return false;
}
标签:mapAll,判断,String,get,parse,嵌套,SDF,HM,区间 From: https://www.cnblogs.com/w852894903/p/16821979.html