Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oleglomako/5e82e2adfc8208df438d9c193164dd8c to your computer and use it in GitHub Desktop.
Save oleglomako/5e82e2adfc8208df438d9c193164dd8c to your computer and use it in GitHub Desktop.
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