Last active
December 12, 2020 17:56
-
-
Save ezhov-da/ded1085c7a0c677f75fa854f9ac0f079 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
public class T { | |
public static void main(String[] args) { | |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); | |
LocalDate startDate = LocalDate.parse("28.01.2009", formatter); | |
LocalDate endDate = LocalDate.parse("05.03.2013", formatter); | |
Period period = Period.between(startDate, endDate); | |
System.out.println(period.getYears()); // 4 | |
System.out.println(period.getMonths()); // 1 | |
System.out.println(period.getDays()); // 5 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment