/* 开始时间 */ Date leftStartDate = feesPreferential.getPreferentialStartTime(); /* 结束时间 */ Date leftEndDate = feesPreferential.getPreferentialEndTime(); /*比较的时间段*/ Date rightStartDate = (Date) feesPreferentialList.get(i).get("preferentialStartTime"); Date rightEndDate = (Date) feesPreferentialList.get(i).get("preferentialEndTime"); /*判断*/ if (((leftStartDate.getTime() >= rightStartDate.getTime()) && leftStartDate.getTime() < rightEndDate.getTime()) || ((leftStartDate.getTime() > rightStartDate.getTime()) && leftStartDate.getTime() <= rightEndDate.getTime()) || ((rightStartDate.getTime() >= leftStartDate.getTime()) && rightStartDate.getTime() < leftEndDate.getTime()) || ((rightStartDate.getTime() > leftStartDate.getTime()) && rightStartDate.getTime() <= leftEndDate.getTime())){ System.out.println("两段时间存在交集"); } System.out.println("两段时间不存在交集");