Close

Java Date Time - YearMonth.getMonthValue() Examples

Java Date Time Java Java API 


Class:

java.time.YearMonth

java.lang.Objectjava.lang.Objectjava.time.YearMonthjava.time.YearMonthjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public int getMonthValue()

Returns the month-of-year field as int from 1 to 12.


Examples


package com.logicbig.example.yearmonth;

import java.time.YearMonth;

public class GetMonthValueExample {

public static void main(String... args) {
YearMonth y = YearMonth.of(2010, 11);
System.out.println(y);

int v = y.getMonthValue();
System.out.println(v);
}
}

Output

2010-11
11




See Also