java.time – Month


java.time.Month Enum


”;


Introduction

The java.time.Month Enum represents a month-of-year, such as ”July”.

Class declaration

Following is the declaration for java.time.Month Enum −

public enum Month
   extends Enum<Month>
      implements TemporalAccessor, TemporalAdjuster

Enum Constants

Following are the fields for Java.time.Month Enum −

  • JANUARY − The singleton instance for the month of January with 31 days.

  • FEBRUARY − The singleton instance for the month of February with 28 days, or 29 in a leap year.

  • MARCH − The singleton instance for the month of March with 31 days.

  • APRIL − The singleton instance for the month of April with 30 days.

  • MAY − The singleton instance for the month of May with 31 days.

  • JUNE − The singleton instance for the month of June with 30 days.

  • JULY − The singleton instance for the month of July with 31 days.

  • AUGUST − The singleton instance for the month of August with 31 days.

  • SEPTEMBER − The singleton instance for the month of September with 30 days.

  • OCTOBER − The singleton instance for the month of October with 31 days.

  • NOVEMBER − The singleton instance for the month of November with 30 days.

  • DECEMBER − The singleton instance for the month of December with 31 days.

Enum methods

Sr.No. Method & Description
1 Temporal adjustInto(Temporal temporal)

Adjusts the specified temporal object to have the same month-of-year as this object.

2 int firstDayOfYear(boolean leapYear)

Gets the day-of-year corresponding to the first day of this month.

3 Month firstMonthOfQuarter()

Gets the month corresponding to the first month of this quarter.

4 static Month from(TemporalAccessor temporal)

Obtains an instance of Month from a temporal object.

5 int get(TemporalField field)

Gets the value of the specified field from this month-of-year as an int.

6 String getDisplayName(TextStyle style, Locale locale)

Gets the textual representation, such as ”Jan” or ”December”.

7 long getLong(TemporalField field)

Gets the value of the specified field from this month-of-year as a long.

8 int getValue()

Gets the month-of-year int value.

9 boolean isSupported(TemporalField field)

Checks if the specified field is supported.

10 int length(boolean leapYear)

Gets the length of this month in days.

11 int maxLength()

Gets the maximum length of this month in days.

12 int minLength()

Gets the minimum length of this month in days.

13 Month minus(long months)

Returns the month-of-year that is the specified number of months before this one.

14 static Month of(int month)

Obtains an instance of Month from an int value.

15 Month plus(long months)

Returns the month-of-year that is the specified number of quarters after this one.

16 <R> R query(TemporalQuery<R> query)

Queries this offset using the specified query.

17 ValueRange range(TemporalField field)

Gets the range of valid values for the specified field.

18 static Month valueOf(String name)

Returns the enum constant of this type with the specified name.

19 static Month[] values()

Returns an array containing the constants of this enum type, in the order they are declared.

Methods inherited

This class inherits methods from the following classes −

  • Java.lang.Enum
  • Java.lang.Object

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *