Close

Java Date Time - YearMonth.getMonth() 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 Month getMonth()

Returns the month-of-year field of this YearMonth object as Month enum.


Examples


package com.logicbig.example.yearmonth;

import java.time.Month;
import java.time.YearMonth;

public class GetMonthExample {

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

Month month = y.getMonth();
System.out.println(month);
}
}

Output

2010-11
NOVEMBER




See Also