Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

homeworkprod opened this Issue · 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?



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

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.


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.


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?


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.


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


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 closed this issue from a commit
@jodastephen jodastephen Add Interval class
Fixes #2
@jodastephen jodastephen added the Fixed label
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.