Home >Java >javaTutorial >How to Calculate the Day Difference Between Two Joda-Time DateTime Instances?
Finding the Day Difference between Joda-Time Dates
Question:
How can I calculate the difference in days between two Joda-Time DateTime instances, regardless of the specific time components (hours, minutes, seconds)?
Answer:
To find the number of days between two dates, ignoring the time components, you can use the toLocalDate method to convert the DateTime objects to LocalDate objects. Then, use the Days class to calculate the difference between the two LocalDate objects:
Days.daysBetween(start.toLocalDate(), end.toLocalDate()).getDays()
Additional Notes:
The above is the detailed content of How to Calculate the Day Difference Between Two Joda-Time DateTime Instances?. For more information, please follow other related articles on the PHP Chinese website!