Created
February 16, 2020 18:07
-
-
Save oleglomako/5e82e2adfc8208df438d9c193164dd8c to your computer and use it in GitHub Desktop.
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
import java.time.LocalDate; | |
import java.time.format.DateTimeFormatter; | |
import java.time.temporal.ChronoUnit; | |
public class PeriodCalculator { | |
public static void main(String[] args) { | |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); | |
LocalDate startDate = LocalDate.parse("29/02/2020", formatter); | |
LocalDate endDate = LocalDate.parse("01/04/2020", formatter); | |
System.out.println(ChronoUnit.DAYS.between(startDate,endDate)); // 32 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment