YearMonth of(int, Month) method in Java with Examples
The of(int year, Month month) method of the YearMonth class in Java is used to get an instance of YearMonth from a year and month.
public static YearMonth of( int year, Month month)
Parameters: This method accepts two parameters:
- year: It represents year.
- month: It represents the month of year.
Return value: This method returns the year-month.
Exceptions: This method throws DateTimeException if the value of any field is invalid.
Below programs illustrate the of(int year, Month month) method of YearMonth in Java:
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.