This example shows how to find how many days are between two dates using Java 8 date time api and Joda time. We will first subtract 1 day from the current date and then find the days between the start and end date. In a comparable example we demonstrate how to find the difference between two dates in days using groovy.
Java 8 Date and Time API
This snippet will calculate days between two dates using java 8 Period.between and ChronoUnit.DAYS.between. Each approach will calculate the amount of time between two temporal objects in the form of days. Something to note, a ChronoUnit gives an absolute count of days, whereas Period is an abstraction for more units than just the day.
Joda Time
This snippet will find the difference between two dates in the number of days using joda.