Month from() method in Java
The from() is a built-in method of the Month ENUM which is used to create a Month instance from a temporal object passed to it as a parameter.
static Month from( TemporalAccessor temporal )
Parameters: This method accepts a single parameter which is a temporal object and cannot be NULL.
Return Value: This method returns a Month instance obtained from a temporal object passed to it as a parameter.
Exception: It throws a DateTimeException if it is not possible to convert the temporal object to a valid month instance.
Below programs illustrate the above 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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.