Gregorian Calendar

Gregorian Calendar is a concrete implementation of a Calendar that implements the normal Gregorian calendar with which you are familiar. The getInstance( ) method of 'Calendar returns a GregorianCalendar initialized with the current date and time the default locale and time zone. .' , Gregorian Calendar defines two fields: CD and BC..These represent the two eras defined by the Gregorian calendar. There are also several constructors for Gregorian Calendar objects. The default, GregorianCalendar(), initializes the object with the current date and time injhe default locale and time zone. Three more constructors offer increasing levels of specificity:
GregorianCalendar(int yenr, int month, int deny Of Moll) regorianCalendar(int,year, int month, int dayOfMontll, int Ho'urs, hit minutes)
GregorianCalendar(int yenr, int month, int dnyOfMontll, int hours, int minutes, 'int seconds) bll- three versions set the day, month, and year. Here, yenr specifies the number of years that have elapsed since 1900.The month is specified by month, with zero indicating January. The day of the month is specified by dnyOfMontll. The first version sets the time to midnight. TIle second, version also sets the hours and the minutes. The third version adds seconds. You can also construct a GregorianCalendar object by specifying either the locale and/ or time zone. The following constructors create objects initialized with the current date and time using the specified time zone and/ or locale: GregorianCa lendar(Locale locnle) ,GregorianCale;tdar(TimeZone timeZone) , Grego.tianGalei:ldar(TimeZone timeZone, Locale locale)
GregorianCalendar provides an implementation of all the abstract methods in Caiendar. It also provides some additional methods. Perhaps the'most interesting is isLeapYear(), which tests'if the year is a leap year. Its form is " boolean isLeap Year(int yenr) This method returns true if yenr is a leap year and false otherwise. The following program demonstrates GregorianCalendar: Sample output is shown here::

Date: Jan 25 1999

Time: 11:25:27
The current not a leap year

Share This