Sunday, June 14, 2026
HomeLanguagesJavaMonth firstMonthOfQuarter() method in Java

Month firstMonthOfQuarter() method in Java

The firstMonthOfQuarter() is a built-in method of the Month ENUM which is used to get the first month corresponding to this quarter. The quarter is defined by dividing the year into 4 groups as:

  • Group 1: JANUARY, FEBRUARY, MARCH
  • Group 2: APRIL, MAY, JUNE
  • Group 3: JULY, AUGUST, SEPTEMBER
  • Group 4: OCTOBER, NOVEMBER, DECEMBER

Syntax:

public int firstMonthOfQuarter()

Parameters: This method does not accepts any parameters.

Return Value: This method returns the month corresponding to the first month of this quarter.

Below programs illustrate the above method:

Program 1:




import java.time.*;
import java.time.Month;
import java.time.temporal.Temporal;
  
class DayOfWeekExample {
    public static void main(String[] args)
    {
        // Set the month to february, 1st Quarter
        Month month = Month.of(2);
  
        // Get the first month of this quarter
        System.out.println(month.firstMonthOfQuarter());
    }
}


Output:

JANUARY

Program 2:




import java.time.*;
import java.time.Month;
import java.time.temporal.Temporal;
  
class DayOfWeekExample {
    public static void main(String[] args)
    {
        // Set the month to JUNE, 2nd Quarter
        Month month = Month.of(6);
  
        // Get the first month of this quarter
        System.out.println(month.firstMonthOfQuarter());
    }
}


Output:

APRIL

Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Month.html#firstMonthOfQuarter–

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS