YearMonth getMonthValue() method in Java Last Updated : 28 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The getMonthValue() method of YearMonth class in Java is used to get the value of the month field from this YearMonth instance with which it is used. It returns the value of the month field as an integer between 1-12 denoting months from January to December. Syntax: public int getMonthValue() Parameter: This method does not accepts any parameter. Return Value: It returns the value of the month field as an integer between 1-12 denoting months from January to December. Below programs illustrate the getMonthValue() method of YearMonth in Java: Program 1: Java // Program to illustrate the getMonthValue() method import java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; public class GfG { public static void main(String[] args) { // Create a YearMonth object YearMonth thisYearMonth = YearMonth.of(2017, 8); // Get the month field System.out.println(thisYearMonth.getMonthValue()); } } Output: 8 Program 2: Java // Program to illustrate the getMonthValue() method import java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; public class GfG { public static void main(String[] args) { // Create a YearMonth object YearMonth thisYearMonth = YearMonth.of(2018, 5); // Get the month field System.out.println(thisYearMonth.getMonthValue()); } } Output: 5 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/YearMonth.html#getMonthValue-- Comment More infoAdvertise with us Next Article Month getValue() method in Java G gopaldave Follow Improve Article Tags : Misc Java Java-Functions Java-time package Java-YearMonth +1 More Practice Tags : JavaMisc Similar Reads YearMonth getMonth() method in Java The getMonth() method of YearMonth class in Java is used to get the month field from this YearMonth instance with which it is used. It returns the month field as a Month instance. Syntax: public Month getMonth() Parameter: This method does not accepts any parameter. Return Value: It returns the mont 1 min read YearMonth getMonth() method in Java The getMonth() method of YearMonth class in Java is used to get the month field from this YearMonth instance with which it is used. It returns the month field as a Month instance. Syntax: public Month getMonth() Parameter: This method does not accepts any parameter. Return Value: It returns the mont 1 min read Month getValue() method in Java The getValue() method is a built-in method of the Month ENUM which is used to get the value of the month-of-year from this Month instance as an integer. The value returned by this method is in the range of 1-12, representing months from January to December. Syntax: public int getValue() Parameters: 1 min read Month getValue() method in Java The getValue() method is a built-in method of the Month ENUM which is used to get the value of the month-of-year from this Month instance as an integer. The value returned by this method is in the range of 1-12, representing months from January to December. Syntax: public int getValue() Parameters: 1 min read YearMonth getYear() method in Java The getYear() method of YearMonth class in Java is used to get the value of the Year field from this YearMonth instance with which it is used. It returns the value of the year field as an integer from MIN_YEAR to MAX_YEAR. Syntax: public int getYear() Parameter: This method does not accepts any para 1 min read YearMonth getYear() method in Java The getYear() method of YearMonth class in Java is used to get the value of the Year field from this YearMonth instance with which it is used. It returns the value of the year field as an integer from MIN_YEAR to MAX_YEAR. Syntax: public int getYear() Parameter: This method does not accepts any para 1 min read Like