Calculate the number of days between two dates in Java 1.8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// input dates | |
final String start = "2010-01-15"; | |
final String end = "2011-03-18"; | |
// parse the dates | |
final LocalDate startDate = LocalDate.parse( start ); | |
final LocalDate endDate = LocalDate.parse( end ); | |
// calculate the number of days between start and end dates | |
long daysDuration = ChronoUnit.DAYS.between( startDate , endDate ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment