Search code examples
java-8period

Get the Period between two local date instances like P1Y2M10DT2H30M


How can I obtain the Period between two different LocalDate instances using Java.

I googled, not able to find it.


Solution

  • A Period is the amount of time between two LocalDate. Same concept as Duration. Here's the difference between the two: A Duration measures an amount of time using time-based values (seconds, nanoseconds). A Period uses date-based values (years, months, days). However, using Period you can't get the hours, mins as you mentioned in the problem statement above.