Some constants of GregorianCalendar.
1. GregorianCalendar.AUGUST:
Syntax:
int java.util.Calendar.AUGUST: 7
Value of the MONTH field indicates the eighth month of the year in the Gregorian and Julian calendars.
2. GregorianCalendar.DATE:
Syntax:
int java.util.Calendar.DATE: 5
Field number for getting 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.
3. GregorianCalendar.DAY_OF_MONTH:
Syntax:
int java.util.Calendar.DAY_OF_MONTH: 5
Field number for getting 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.
4. GregorianCalendar.DAY_OF_WEEK:
Syntax:
int java.util.Calendar.DAY_OF_WEEK: 7
Field number for getting and set indicating the day of the week. This field takes values SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY.
5. GregorianCalendar.DAY_OF_WEEK_IN_MONTH:
Syntax:
int java.util.Calendar.DAY_OF_WEEK_IN_MONTH: 8
Field number for getting and set indicating the ordinal number of the day of the week within the current month.
6. GregorianCalendar.DAY_OF_YEAR:
Syntax:
int java.util.Calendar.DAY_OF_YEAR: 6
Field number for getting 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.GregorianCalendar;public class GregorianCalendarConstant2 {public static void main(String[] args) {System.out.println(GregorianCalendar.AUGUST);System.out.println(GregorianCalendar.DATE);System.out.println(GregorianCalendar.DAY_OF_MONTH);System.out.println(GregorianCalendar.DAY_OF_WEEK);System.out.println(GregorianCalendar.DAY_OF_WEEK_IN_MONTH);System.out.println(GregorianCalendar.DAY_OF_YEAR);}}
Output:
7 5 5 7 8 6
7. GregorianCalendar.MONDAY:
Syntax:
int java.util.Calendar.MONDAY: 2
Value of the DAY_OF_WEEK field indicating Monday.
8. GregorianCalendar.MONTH
Syntax:
int java.util.Calendar.MONTH: 2
Field number for get and set indicating the month.
9. GregorianCalendar.NARROW_FORMAT
Syntax:
int java.util.Calendar.NARROW_FORMAT: 4
A style specifier for getDisplayName and getDisplayNames indicates a narrow name used for format.
10. GregorianCalendar.NARROW_STANDALONE
Syntax:
int java.util.Calendar.NARROW_STANDALONE: 32772
A style specifier for getDisplayName and getDisplayNames indicating a narrow name independently.
Syntax:
11. GregorianCalendar.NOVEMBER
Syntax:
int java.util.Calendar.NOVEMBER: 10
Value of the MONTH field indicates the eleventh month of the year in the Gregorian and Julian calendars.
12. GregorianCalendar.OCTOBER
Syntax:
int java.util.Calendar.OCTOBER: 9
Value of the MONTH field indicates the tenth month of the year in the Gregorian and Julian calendars.
Approach
Java
import java.util.GregorianCalendar;public class GregorianCalendarConstant6 {public static void main(String[] args) {System.out.println(GregorianCalendar.MONDAY);System.out.println(GregorianCalendar.MONTH);System.out.println(GregorianCalendar.NARROW_FORMAT);System.out.println(GregorianCalendar.NARROW_STANDALONE);System.out.println(GregorianCalendar.NOVEMBER);System.out.println(GregorianCalendar.OCTOBER);}}
Output:
2 2 4 32772 10 9
No comments:
Post a Comment