Calendar class constants in Java Part-V

1. Calendar.JANUARY

int java.util.Calendar.JANUARY: 0

Value of the MONTH field indicates the first month of the year in the Gregorian and Julian calendars.

2. Calendar.FEBRUARY

int java.util.Calendar.FEBRUARY: 1

Value of the MONTH field indicates the second month of the year in the Gregorian and Julian calendars.

3. Calendar.MARCH

int java.util.Calendar.MARCH: 2

Value of the MONTH field indicates the third month of the year in the Gregorian and Julian calendars.

4. Calendar.APRIL

int java.util.Calendar.APRIL: 3

Value of the MONTH field indicates the fourth month of the year in the Gregorian and Julian calendars.

5. Calendar.MAY

int java.util.Calendar.MAY: 4

Value of the MONTH field indicates the fifth month of the year in the Gregorian and Julian calendars.

6. Calendar.JUNE

int java.util.Calendar.JUNE: 5

Value of the MONTH field indicating the sixth month of the year in the Gregorian and Julian calendars.

7. Calendar.JULY

int java.util.Calendar.JULY: 6

Value of the MONTH field indicating the seventh month of the year in the Gregorian and Julian calendars.

8. Calendar.AUGUST

int java.util.Calendar.AUGUST: 7

Value of the MONTH field indicating the eighth month of the year in the Gregorian and Julian calendars.

9. Calendar.SEPTEMBER

int java.util.Calendar.SEPTEMBER: 8

Value of the MONTH field indicating the ninth month of the year in the Gregorian and Julian calendars.

10. Calendar.OCTOBER

int java.util.Calendar.OCTOBER: 9

Value of the MONTH field indicating the tenth month of the year in the Gregorian and Julian calendars.

11. Calendar.NOVEMBER 

int java.util.Calendar.NOVEMBER: 10

Value of the MONTH field indicating the eleventh month of the year in the Gregorian and Julian calendars.

12. Calendar.DECEMBER

int java.util.Calendar.DECEMBER: 11

Value of the MONTH field indicating the twelfth month of the year in the Gregorian and Julian calendars.

Approach

Java

import java.util.Calendar;

public class CalendarConstantsMonths {
    public static void main(String[] args) {

        System.out.println(Calendar.JANUARY);
        System.out.println(Calendar.FEBRUARY);
        System.out.println(Calendar.MARCH);
        System.out.println(Calendar.APRIL);

        System.out.println(Calendar.MAY);
        System.out.println(Calendar.JUNE);
        System.out.println(Calendar.JULY);
        System.out.println(Calendar.AUGUST);
        System.out.println(Calendar.SEPTEMBER);

        System.out.println(Calendar.OCTOBER);
        System.out.println(Calendar.NOVEMBER);
        System.out.println(Calendar.DECEMBER);

    }
}

Output:

0 1 2 3 4 5 6 7 8 9 10 11


No comments:

Post a Comment