I have seen that you are using LocalDateTime and LocalTime in Java, these classes have methods to know if they overlap:
boolean isAfter(ChronoLocalDateTime<?> other) ➔ Checks if this date-time is after the specified date-time.
boolean isBefore(ChronoLocalDateTime<?> other) ➔ Checks if this date-time is before the specified date-time.
boolean isEqual(ChronoLocalDateTime<?> other) ➔ Checks if this date-time is equal to the specified date-time.
You could just get the last date from your range1 and the first from your second range. And play with this