static void setFlag(String recordStartTime,String recordEndTime,String startTime,String endTime,List<ReservableVo.DataDTO.MeetingReservationRecord> hourList){ StringBuilder sb1 = new StringBuilder(); sb1.append("2000-01-01"); sb1.append(" "); StringBuilder sb2 = new StringBuilder(); sb2.append("2000-01-01"); sb2.append(" "); StringBuilder sb3 = new StringBuilder(); sb3.append("2000-01-01"); sb3.append(" "); StringBuilder sb4 = new StringBuilder(); sb4.append("2000-01-01"); sb4.append(" "); StringBuilder sb5 = new StringBuilder(); sb5.append("2000-01-01"); sb5.append(" "); StringBuilder sb6 = new StringBuilder(); sb6.append("2000-01-01"); sb6.append(" "); Date recordStartDate = DateTimeUnits.StringFormatDate2(sb1.append(recordStartTime).toString()); Date recordEndDate = DateTimeUnits.StringFormatDate2(sb2.append(recordEndTime).toString()); Date meetStartDate = DateTimeUnits.StringFormatDate2(sb3.append(startTime).toString()); Date meetEndDate = DateTimeUnits.StringFormatDate2(sb4.append(endTime).toString()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH"); //预约记录开始小时 int recordStartHourInt = Integer.valueOf(simpleDateFormat.format(DateTimeUnits.StringFormatDate2(sb1.toString()))); //预约记录结束小时 int recordEndHourInt = 0; String endMinute = recordEndTime.substring(3); Integer endMinutes = Integer.valueOf(endMinute); if (endMinutes > 0){ recordEndHourInt = Integer.valueOf(simpleDateFormat.format(DateTimeUnits.addTime(DateTimeUnits.StringFormatDate2(sb2.toString()), 1))); } else if (endMinute.equals("00")) { recordEndHourInt = Integer.valueOf(simpleDateFormat.format(DateTimeUnits.StringFormatDate2(sb2.toString()))); } if (recordEndHourInt == 0){ recordEndHourInt = 24; } String recordStartHourString = String.valueOf(recordStartHourInt) + ":00"; if (recordStartHourInt >= 0 && recordStartHourInt <= 9){ recordStartHourString = "0" + recordStartHourString; } String recordEndHourString = String.valueOf(recordEndHourInt) + ":00"; if (recordEndHourInt >= 0 && recordEndHourInt <= 9){ recordEndHourString = "0" + recordEndHourString; } Date recordStartHourDate = DateTimeUnits.StringFormatDate2(sb5.append(recordStartHourString).toString()); Date recordEndHourDate = DateTimeUnits.StringFormatDate2(sb6.append(recordEndHourString).toString()); if ( meetStartDate.compareTo(recordStartDate) <= 0 && recordEndDate.compareTo(meetEndDate) <= 0 && recordStartDate.compareTo(recordEndDate) <= 0 && meetStartDate.compareTo(meetEndDate) <= 0){ for (ReservableVo.DataDTO.MeetingReservationRecord hour : hourList) { String startHour = hour.getStartHour(); String endHour = hour.getEndHour(); StringBuilder sb7 = new StringBuilder(); sb7.append("2000-01-01"); sb7.append(" "); StringBuilder sb8 = new StringBuilder(); sb8.append("2000-01-01"); sb8.append(" "); Date startHourDate = DateTimeUnits.StringFormatDate2(sb7.append(startHour).toString()); Date endHourDate = DateTimeUnits.StringFormatDate2(sb8.append(endHour).toString()); if (recordStartHourDate.compareTo(startHourDate) <= 0 && endHourDate.compareTo(recordEndHourDate) <= 0 && recordStartDate.compareTo(recordEndDate) <= 0 && startHourDate.compareTo(endHourDate) <= 0){ // hour.setFlag(1); }else { // hour.setFlag(0); } } } }
标识时间段
最新推荐文章于 2024-11-01 14:48:20 发布