How can we get duration between two dates or time in Java 8?

In Java8, we have a new class Duration that provides the utility of computing duration between two dates.

We can call the static method Duration.between(date1, date2) to get the time period in hours, mins, days etc. between date1 and date2.

Leave a Reply

Your email address will not be published. Required fields are marked *