Period is used to model a quantity or amount of time in terms of years, months, and days, ideal for calculating differences between dates.
Source Code
LocalDate start = LocalDate.of(2023, 1, 1);
LocalDate end = LocalDate.of(2023, 12, 31);
Period period = Period.between(start, end);
System.out.println("Period: " + period.getYears() + " Year(s) "
+ period.getMonths() + " Month(s) "
+ period.getDays() + " Day(s)");