Java Date Time Java Java API
Class:
java.time.LocalDate
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()); }
}
Output8
|