Java LocalDate getMonth() Method
Example
Get the month of a date:
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate myDate = LocalDate.of(2026, 1, 15);
System.out.println(myDate.getMonth());
}
}
Definition and Usage
The getMonth() method returns the month of the date, as a Month value.
Month is an enum (a fixed list of values) with the twelve months, from JANUARY to DECEMBER. When you print it, the name is shown in capital letters.
Tip: Use getMonthValue() to get the month as a number from 1 to 12.
Syntax
public Month getMonth()
Parameter Values
None.
Technical Details
| Returns: | The month, as a Month value, for example JANUARY. |
|---|
Related Pages
❮ Date and Time Methods