Intersecting overlapping intervals in Java
问题 I have an input set of date ranges that may overlap. Instead of combining these overlapping date ranges, I want to create new date ranges with adjusted dates, e.g.: |---------------------–| |-----| |--------------–| should end up in: |-------|---|-|--------|----| Is there an efficient way to solve this with Java? Thanks in advance! UPDATE: I didn't mention my own approach in my first question, so here it is: I'd simply take the start and the end date of an interval and add it to a sorted set.