Close

Java Date Time - LocalDate.getMonthValue() Examples

Java Date Time Java Java API 


Class:

java.time.LocalDate

java.lang.Objectjava.lang.Objectjava.time.LocalDatejava.time.LocalDatejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.time.chrono.ChronoLocalDateChronoLocalDatejava.io.SerializableSerializableLogicBig

Method:

public int getMonthValue()

Returns the month as an integer value from 1 to 12.

We would prefer to use the method LocalDate#getMonth() as compare to this method, specially if we just want to display the month field.


Examples


package com.logicbig.example.localdate;

import java.time.LocalDate;
import java.time.Month;

public class GetMonthValueExample {

public static void main (String... args) {
LocalDate d = LocalDate.of(2015, Month.AUGUST, 11);
System.out.println(d.getMonthValue());
}

}

Output

8




See Also