Close

Java Date Time - MonthDay.getMonthValue() Examples

Java Date Time Java Java API 


Class:

java.time.MonthDay

java.lang.Objectjava.lang.Objectjava.time.MonthDayjava.time.MonthDayjava.time.temporal.TemporalAccessorTemporalAccessorjava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public int getMonthValue()

This method returns the value of month-of-year field of this MonthDay object.


Examples


package com.logicbig.example.monthday;

import java.time.Month;
import java.time.MonthDay;

public class GetMonthValueExample {

public static void main(String... args) {
MonthDay m = MonthDay.of(5, 21);
System.out.println(m);

int v = m.getMonthValue();
System.out.println(v);

//alternatively
Month month = m.getMonth();
int v2 = month.getValue();
System.out.println(v2);
}
}

Output

--05-21
5
5




See Also