The atMonthDay(MonthDay) method of Year class in Java combines the current year object with a month-day object passed as parameter to it to create a LocalDate object.
public LocalDate atMonthDay(MonthDay monthDay)
Parameter: This method accepts a single parameter monthDay. It is the MonthDay object which specifies a month-day to use. It takes a valid MonthDay object and cannot be NULL.
Return Value: It returns a LocalDate object formed by the current year object and a valid MonthDate object passed as parameter to the function.
Note: If the current year is not a leap year and the MonthDay object passed as parameter specifies “29th February”, it will be automatically rounded to “28th February” in the resulting LocalDate object.
Below programs illustrate the atMonthDay(MonthDay) method of Year in Java:
Program 2: Since 2018 is not a leap year, the day 29 will be rounded off to 28 in the below program.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.