Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6850047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:04:34+00:00 2026-05-27T01:04:34+00:00

I have a bunch of Joda time Interval objects stored in a List. All

  • 0

I have a bunch of Joda time Interval objects stored in a List. All of these Intervals have valid start and end instants. These Intervals can have any overlaps, abuts or even gaps among themselves.

I want to flatten (optimize) these Intervals to the maximum possible. I mean, I have to generate other Interval objets that will represent the very same from – to information, but without redundancy.

For example:

I1: 2012-01-12T05:00:00.000/2013-03-18T14:00:00.000

I2: 2012-04-12T04:00:00.000/2013-02-10T06:00:00.000

I3: 2015-12-12T04:00:00.000/2016-12-12T06:00:00.000

Should produce:

I1_o: 2012-01-12T05:00:00.000/2013-03-18T14:00:00.000

I2_o: 2015-12-12T04:00:00.000/2016-12-12T06:00:00.000

(I2 is absolutely within I1, so can be ignored, and the resulted two has a gap).

I know the three methods in Interval class that can help me, but I guess I need a more generic algorithm that can search overlaps between some kind of intervals, like ordinary numbers, etc.
Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:04:35+00:00Added an answer on May 27, 2026 at 1:04 am

    Sort the intervals by start time and loop through the intervals. If the start time of interval i is less than or equal to the end time of interval i-1, they can be merged into one interval whose end time is the greatest end time of the two original intervals. (Put the resulting intervals into a new list so that you can safely loop through the sorted list of original intervals without modifying it.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

week DKK id=radio2 value=75 /> I have bunch of these div entry generated by
I have bunch of html and I need to get all the anchors and
I have bunch of objects that return a DOM-tree that I then use to
I have a bunch of files which contain an ascii header with a time
I have a bunch of buttons that all use the same .click() method. How
If i have bunch of classes in objectspace and have a list of methods
For example I have bunch of functions like these: function a() { //do something
I have bunch of data objects that I populate after getting data from a
I have bunch of dates in format YYYY-MM-DD But I have all year in
I have a bunch of strings in php that all look like this: 10

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.