0

I am looking for an algorithm which checks if a LocalTime pair overlaps with an ArrayList of LocalTime pairs.

I've tried manually adding several if's, but I'm not covering all cases.

public boolean formsOverlap() {

    for (ControlSchedule cs: table.getItems()) {

        if (startSpinner.getValue().isAfter(cs.getStartTime())
            && startSpinner.getValue().isBefore(cs.getEndTime()))
            return true;
        if (endSpinner.getValue().isAfter(cs.getStartTime())
            && endSpinner.getValue().isBefore(cs.getEndTime()))
            return true;
        if (cs.getStartTime().isAfter(startSpinner.getValue())
            && cs.getEndTime().isBefore(endSpinner.getValue()))
            return true;
        }

        return false;
    }
AwesomeGuy
  • 537
  • 1
  • 6
  • 17

0 Answers0