Scenario 1:
- R1 = 02/08/2018 - 20/08/2018
- R2 = 06/08/2018 - 29/08/2018 - R1 |--------------| R2 |---------------------|
Scenario 2:
- R1 = 02/08/2018 - 20/08/2018
- R2 = 31/08/2018 - 16/09/2018 - R1 |--------------| R2 |---------------------|
There are two different date ranges, and I need to compare these ranges to find out if they intersect or not. For example, in the first scenario, the ranges intersect and in the second scenario they do not. The dates are in dd/MM/yyyy format.
What is the best way to determine if they intersect or not using Java?
       def R1Initial = SDF.parse(u.effectiveStartDate.text())
       def R1End = SDF.parse(u.mdfSystemEffectiveEndDate.text())
       def R2Initial = SDF.parse(u.effectiveStartDate.text())
       def R2End = SDF.parse(u2.mdfSystemEffectiveEndDate.text())
       def intersects = ?????
 
     
     
    