You are not using the class correctly Periodhere. startrepresents the date 01/01/2016(in format dd/MM/yyyy). When you add a period of 1 month, the result will be a date 01/02/2016.
The period between these two dates, determined by the class Period, is “1 month”. If you print a period, you will get "P1M"that is a template to say that:
Time in the ISO-8601 database based on a date, for example, "2 years, 3 months, and 4 days."
, getDays(), , 0. . , getMonths, 1:
public static void main(String[] args) {
LocalDate start = LocalDate.of(2016, 01, 01);
Period period = Period.between(start, start.plus(Period.ofMonths(1)));
System.out.println(period.getDays());
System.out.println(period.getMonths());
}
, , . :
for (Month month : Month.values()) {
System.out.println(month.length(Year.now().isLeap()));
}
Java Time enum Month , length(leapYear) , . , , .
, Year.now() , isLeap().
, , ChronoUnit.DAYS.between(start, end).