Calendar class constants in Java Part -I

1. Calendar.ALL_STYLES: 

int java.util.Calendar.ALL_STYLES : 0

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

2. Calendar.AM:

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.

3. Calendar.AM_PM:

int java.util.Calendar.AM_PM : 9

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

4. Calendar.DATE:

int java.util.Calendar.DATE: 5

Field number for get and set indicating the day of the month. This is a synonym for DAY_OF_MONTH. The first day of the month has a value of 1.

5. Calendar.DAY_OF_MONTH:

int java.util.Calendar.DAY_OF_MONTH: 5

Field number for get and set indicating the day of the month. This is a synonym for DATE. The first day of the month has a value of 1.

6. Calendar.DAY_OF_WEEK:

int java.util.Calendar.DAY_OF_WEEK : 7

Field number for get and set indicating the day of the week. This field takes values SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY.

7. Calendar.DAY_OF_WEEK_IN_MONTH:

int java.util.Calendar.DAY_OF_WEEK_IN_MONTH : 8

Field number for get and set indicating the ordinal number of the day of the week within the current month.

8. Calendar.DAY_OF_YEAR:

int java.util.Calendar.DAY_OF_YEAR: 6

Field number for get and set indicating the day number within the current year. The first day of the year has a value of 1.

Approach

Java

import java.util.Calendar;

public class CalendarConstans1 {
    public static void main(String[] args) {
        System.out.println(Calendar.ALL_STYLES);

        System.out.println(Calendar.AM);
        System.out.println(Calendar.AM_PM);

        System.out.println(Calendar.DATE);
        System.out.println(Calendar.DAY_OF_MONTH);

        System.out.println(Calendar.DAY_OF_WEEK);
        System.out.println(Calendar.DAY_OF_WEEK_IN_MONTH);

        System.out.println(Calendar.DAY_OF_YEAR);

    }
}

Output:

0 0 9 5 5 7 8 6


No comments:

Post a Comment