Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to jodatime Interval in Java 8 Date and Time API [duplicate]

The Java 8 way of dealing with time seems to have improved so much that I start to think about replacing jodatime in some cases. But what I am missing is an equivalent to the Interval class.

I haven't dug too deep into Java 8 yet, so I might have missed something there. Does anyone have ideas on how intervals could be best dealt with?

like image 515
nansen Avatar asked Apr 05 '14 19:04

nansen


People also ask

Can you provide some APIs of Java 8 date and time?

Java 8 provides APIs for the easy formatting of Date and Time: LocalDateTime localDateTime = LocalDateTime. of(2015, Month. JANUARY, 25, 6, 30);

What is a Zonedtime in the Java 8 date and time API?

time introduced a new date-time API, most important classes among them are : Local : Simplified date-time API with no complexity of timezone handling. Zoned : Specialized date-time API to deal with various timezones.

What is the replacement of Joda-time Library in Java 8?

Correct Option: D. In java 8,we are asked to migrate to java. time (JSR-310) which is a core part of the JDK which replaces joda library project.

Is Joda-time format followed in Java 8?

Joda-Time is an API created by joda.org which offers better classes and having efficient methods to handle date and time than classes from java. util package like Calendar, Gregorian Calendar, Date, etc. This API is included in Java 8.0 with the java.


1 Answers

No way, the Joda class Interval does not exist in JSR-310. The concepts of Duration, Period etc. denotes temporal amounts without being bound to fixed points in time while an interval has a fixed start and fixed end on the timeline.

By the way, this question is not new and a duplicate. On the other SO-link you can also find a similar answer direct from JodaTime-project-leader.

like image 80
Meno Hochschild Avatar answered Oct 20 '22 02:10

Meno Hochschild