GregorianCalendar constants Part -I

Some constants of GregorianCalendar.

1. GregorianCalendar.AD:

Syntax:

int java.util.GregorianCalendar.AD: 1

Value of the ERA field indicating the common era.

2. GregorianCalendar.ALL_STYLES:

Syntax:

int java.util.Calendar.ALL_STYLES: 0

A style specifier for getDisplayNames indicating names in all styles, such as"January" and "Jan".

3. GregorianCalendar.BC:

Syntax:

int java.util.GregorianCalendar.BC: 0

The value of the ERA field indicates the period before the common era also known as BCE.

4. GregorianCalendar.AM:

Syntax:

int java.util.Calendar.AM: 0

The value of the AM_PM field indicates the period of the day from midnight to just before noon.

5. GregorianCalendar.AM_PM:

Syntax:

int java.util.Calendar.AM_PM: 9

Field number for getting and set indicating whether the HOUR is before or afternoon.

6. GregorianCalendar.APRIL:

Syntax:

int java.util.Calendar.APRIL: 3

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

Approach

Java

import java.util.GregorianCalendar;

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

        System.out.println(GregorianCalendar.AD);
        System.out.println(GregorianCalendar.ALL_STYLES);

        System.out.println(GregorianCalendar.BC);
        System.out.println(GregorianCalendar.AM);

        System.out.println(GregorianCalendar.AM_PM);
        System.out.println(GregorianCalendar.APRIL);

    }
}

Output:

1 0 0 0 9 3


7. GregorianCalendar.LONG_FORMAT:

Syntax:

int java.util.Calendar.LONG_FORMAT: 2

A style specifier for getDisplayName and getDisplayNames indicates a long name used for format.

8. GregorianCalendar.LONG_STANDALONE

Syntax:

int java.util.Calendar.LONG_STANDALONE: 32770

A style specifier for getDisplayName and getDisplayNames indicating a long name is used independently, such as a month name as calendar headers.

9. GregorianCalendar.MARCH

Syntax:

int java.util.Calendar.MARCH: 2

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

10. GregorianCalendar.MAY

Syntax:

int java.util.Calendar.MAY: 4

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

11. GregorianCalendar.MILLISECOND

Syntax:

int java.util.Calendar.MILLISECOND: 14

Field number for getting and set indicating the millisecond within the second.

12. GregorianCalendar.MINUTE

Syntax:

int java.util.Calendar.MINUTE: 12

Field number for getting and set indicating the minute within the hour.

Approach

Java

import java.util.GregorianCalendar;

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

        System.out.println(GregorianCalendar.LONG_FORMAT);
        System.out.println(GregorianCalendar.LONG_STANDALONE);

        System.out.println(GregorianCalendar.MARCH);
        System.out.println(GregorianCalendar.MAY);

        System.out.println(GregorianCalendar.MILLISECOND);
        System.out.println(GregorianCalendar.MINUTE);

    }
}

Output:

2 32770 2 4 14 12


No comments:

Post a Comment