The getMonth() method of an LocalDateTime class is used to return month-of-year field. This field is returned using the Month enum. The enum can provide the primitive int value.
public Month getMonth()
Parameter: This method does not accept any parameter.
Returns: This method returns the enum Month for the month of this LocalDateTime.
Below programs illustrate the LocalDateTime.getMonth() method:
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.