Skip to content

Add `Interval` class similar to Joda-Time #2

homeworkprod opened this Issue Feb 12, 2014 · 9 comments

4 participants


I might have missed it, but neither Java 8 nor ThreeTen-Extra seem to include the Interval class from Joda time.

Is it going to be ported to one or the other? If not, what is the rationale for leaving it out?


ThreeTen member

Neither JDK 8 or ThreeTen-Extra currently have an interval class. This would make a reasonable addition to ThreeTen-Extra. I've adjusted this issue to an RFE.

@jodastephen jodastephen added the RFE label Feb 12, 2014

Thanks for the response, glad to hear that you're considering it.


I'm also interested in having an Interval class with joda's overlap/gap/abuts methods.

raupachz commented Nov 5, 2014

How would one start implementing an Interval class? In Joda the Interval class was build around ReadableInstant. With JSR310 we differentiate between Instant and LocalDateTime, etc. Should we design an JSR310 compatible Interval class around Temporal?

For example we work with LocalDateTime, LocalTime and LocalDate. We often need to compute intersections between two LocalTimes and LocalDateTime. At the moment we stick around with Joda because of the Interval class.

ThreeTen member

There will need to be separate Interval and LocalDateRange classes I suspect, and perhaps more. I'm not sure that generics will help much in abstracting because the methods needed on each are probably different. Maybe start by porting the Joda-Time Interval class?

raupachz commented Nov 6, 2014

Interval for Instant and LocalDateRange for LocalDateTime I suppose?

We implemented a subset of Joda-Time's Interval class. It does not cover the whole range of the original class but it was enough for us at that time. We were unsure about how to deal with Instant, LocalDateTime, LocalTime etc, so we ended up with a class that only works with LocalDateTime. Guess, there could be more improvement.

ThreeTen member

LocalDateRange would be for LocalDate. I've never seen a use case for LocalDateTimeRange myself, but perhaps you have one.

raupachz commented Nov 8, 2014

Well, we have use cases like: how many minutes between midnight and four on a sunday, or is it a holiday and after six.


I added a pull request with a rewrite of a custom class I used in a project.

@jodastephen jodastephen added a commit that closed this issue Dec 9, 2014
@jodastephen jodastephen Add Interval class
Fixes #2
@jodastephen jodastephen added the Fixed label Dec 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.