You are on page 1of 6

What is the Calendar

class and various


methods?

Done by: Abdulaziz Khamis AL-Shabibi


Introduction
 The Calendar class is abstract and provides
methods to convert the time in milliseconds
to the calendar fields such as seconds,
minutes, hours, days, weeks, months, and
years. It makes the manipulation of dates
easy.
 The Calendar class does not provide any
public constructor. It is instantiated using the
Calendar.getInstance() method as follows:
 Calendar c = Calendar.getInstance().
 What is the Calendar class?
 Calendar is an abstract base class for
converting between a Date object and a
set of integer fields such as YEAR,
MONTH, DAY, HOUR, and so on. (A
Date object represents a specific
instant in time with millisecond
precision.
 Insufficient information. The calendar
will use default information to specify
the missing fields. This may vary by
calendar; for the Gregorian calendar,
the default for a field is the same as
that of the start of the epoch: i.e., YEAR
= 1970, MONTH = JANUARY, DATE = 1,
etc.
 Inconsistent information. If fields conflict, the calendar will give
preference to fields set more recently. For example, when
determining the day, the calendar will look for one of the
following combinations of fields. The most recent combination,
as determined by the most recently set single field, will be
used.
 MONTH + DAY_OF_MONTH
 MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
 MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
 DAY_OF_YEAR
 DAY_OF_WEEK + WEEK_OF_YEAR

 For the time of day:
 HOUR_OF_DAY
 AM_PM + HOUR
conclusion
 The Calendar class enables you to dynamically
create calendars. Your calendars can be
formatted through the use of a calendar
template, allowing 100% control over every
aspect of its design. In addition, you can pass
data to your calendar cells.
 By creating a calendar template you have 100%
control over the design of your calendar. Each
component of your calendar will be placed within
a pair of pseudo-variables.

You might also like