Calendar Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
<strong>[icu enhancement]</strong> ICU's replacement for java.util.Calendar
.
[Android.Runtime.Register("android/icu/util/Calendar", ApiSince=24, DoNotGenerateAcw=true)]
public abstract class Calendar : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Lang.ICloneable, Java.Lang.IComparable
[<Android.Runtime.Register("android/icu/util/Calendar", ApiSince=24, DoNotGenerateAcw=true)>]
type Calendar = class
inherit Object
interface ISerializable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
interface ICloneable
interface IComparable
- Inheritance
- Derived
- Attributes
- Implements
Remarks
<strong>[icu enhancement]</strong> ICU's replacement for java.util.Calendar
. Methods, fields, and other functionality specific to ICU are labeled '<strong>[icu]</strong>'.
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. See Date
for information about the Date
class.)
Subclasses of Calendar
interpret a Date
according to the rules of a specific calendar system. ICU4J contains several subclasses implementing different international calendar systems.
Like other locale-sensitive classes, Calendar
provides a class method, getInstance
, for getting a generally useful object of this type. Calendar
's getInstance
method returns a calendar of a type appropriate to the locale, whose time fields have been initialized with the current date and time: <blockquote>
Calendar rightNow = Calendar.getInstance()
</blockquote>
When a ULocale
is used by getInstance
, its 'calendar
' tag and value are retrieved if present. If a recognized value is supplied, a calendar is provided and configured as appropriate. Currently recognized tags are "buddhist", "chinese", "coptic", "ethiopic", "gregorian", "hebrew", "islamic", "islamic-civil", "japanese", and "roc". For example: <blockquote>
Calendar cal = Calendar.getInstance(new ULocale("en_US@calendar=japanese"));
</blockquote> will return an instance of JapaneseCalendar (using en_US conventions for minimum days in first week, start day of week, et cetera).
A Calendar
object can produce all the time field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). Calendar
defines the range of values returned by certain fields, as well as their meaning. For example, the first month of the year has value MONTH
== JANUARY
for all calendars. Other values are defined by the concrete subclass, such as ERA
and YEAR
. See individual field documentation and subclass documentation for details.
When a Calendar
is <em>lenient</em>, it accepts a wider range of field values than it produces. For example, a lenient GregorianCalendar
interprets MONTH
== JANUARY
, DAY_OF_MONTH
== 32 as February 1. A non-lenient GregorianCalendar
throws an exception when given out-of-range field settings. When calendars recompute field values for return by get()
, they normalize them. For example, a GregorianCalendar
always produces DAY_OF_MONTH
values between 1 and the length of the month.
Calendar
defines a locale-specific seven day week using two parameters: the first day of the week and the minimal days in first week (from 1 to 7). These numbers are taken from the locale resource data when a Calendar
is constructed. They may also be specified explicitly through the API.
When setting or getting the WEEK_OF_MONTH
or WEEK_OF_YEAR
fields, Calendar
must determine the first week of the month or year as a reference point. The first week of a month or year is defined as the earliest seven day period beginning on getFirstDayOfWeek()
and containing at least getMinimalDaysInFirstWeek()
days of that month or year. Weeks numbered ..., -1, 0 precede the first week; weeks numbered 2, 3,... follow it. Note that the normalized numbering returned by get()
may be different. For example, a specific Calendar
subclass may designate the week before week 1 of a year as week <em>n</em> of the previous year.
When computing a Date
from time fields, some special circumstances may arise: there may be insufficient information to compute the Date
(such as only year and month but no day in the month), there may be inconsistent information (such as "Tuesday, July 15, 1996" -- July 15, 1996 is actually a Monday), or the input time might be ambiguous because of time zone transition.
<strong>Insufficient information.</strong> 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.
<strong>Inconsistent information.</strong> 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.
<blockquote>
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
</blockquote>
For the time of day:
<blockquote>
HOUR_OF_DAY
AM_PM + HOUR
</blockquote>
<strong>Ambiguous Wall Clock Time.</strong> When time offset from UTC has changed, it produces an ambiguous time slot around the transition. For example, many US locations observe daylight saving time. On the date switching to daylight saving time in US, wall clock time jumps from 12:59 AM (standard) to 2:00 AM (daylight). Therefore, wall clock time from 1:00 AM to 1:59 AM do not exist on the date. When the input wall time fall into this missing time slot, the ICU Calendar resolves the time using the UTC offset before the transition by default. In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist), so the final result will be 2:30 AM daylight time.
On the date switching back to standard time, wall clock time is moved back one hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this case, the ICU Calendar resolves the time using the UTC offset after the transition by default. For example, 1:30 AM on the date is resolved as 1:30 AM standard time.
Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs #setRepeatedWallTimeOption(int)
and #setSkippedWallTimeOption(int)
. These methods are available in ICU 49 or later versions.
<strong>Note:</strong> for some non-Gregorian calendars, different fields may be necessary for complete disambiguation. For example, a full specification of the historial Arabic astronomical calendar requires year, month, day-of-month <em>and</em> day-of-week in some cases.
<strong>Note:</strong> There are certain possible ambiguities in interpretation of certain singular times, which are resolved in the following ways: <ol> <li> 24:00:00 "belongs" to the following day. That is, 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970
<li> Although historically not precise, midnight also belongs to "am", and noon belongs to "pm", so on the same day, 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm </ol>
The date or time format strings are not part of the definition of a calendar, as those must be modifiable or overridable by the user at runtime. Use DateFormat
to format dates.
<strong>Field manipulation methods</strong>
Calendar
fields can be changed using three methods: set()
, add()
, and roll()
.
<strong>set(f, value)
</strong> changes field f
to value
. In addition, it sets an internal member variable to indicate that field f
has been changed. Although field f
is changed immediately, the calendar's milliseconds is not recomputed until the next call to get()
, getTime()
, or getTimeInMillis()
is made. Thus, multiple calls to set()
do not trigger multiple, unnecessary computations. As a result of changing a field using set()
, other fields may also change, depending on the field, the field value, and the calendar system. In addition, get(f)
will not necessarily return value
after the fields have been recomputed. The specifics are determined by the concrete calendar class.
<em>Example</em>: Consider a GregorianCalendar
originally set to August 31, 1999. Calling set(Calendar.MONTH, Calendar.SEPTEMBER)
sets the calendar to September 31, 1999. This is a temporary internal representation that resolves to October 1, 1999 if getTime()
is then called. However, a call to set(Calendar.DAY_OF_MONTH, 30)
before the call to getTime()
sets the calendar to September 30, 1999, since no recomputation occurs after set()
itself.
<strong>add(f, delta)
</strong> adds delta
to field f
. This is equivalent to calling set(f, get(f) + delta)
with two adjustments:
<blockquote>
<strong>Add rule 1</strong>. The value of field f
after the call minus the value of field f
before the call is delta
, modulo any overflow that has occurred in field f
. Overflow occurs when a field value exceeds its range and, as a result, the next larger field is incremented or decremented and the field value is adjusted back into its range.
<strong>Add rule 2</strong>. If a smaller field is expected to be invariant, but it is impossible for it to be equal to its prior value because of changes in its minimum or maximum after field f
is changed, then its value is adjusted to be as close as possible to its expected value. A smaller field represents a smaller unit of time. HOUR
is a smaller field than DAY_OF_MONTH
. No adjustment is made to smaller fields that are not expected to be invariant. The calendar system determines what fields are expected to be invariant.
</blockquote>
In addition, unlike set()
, add()
forces an immediate recomputation of the calendar's milliseconds and all fields.
<em>Example</em>: Consider a GregorianCalendar
originally set to August 31, 1999. Calling add(Calendar.MONTH, 13)
sets the calendar to September 30, 2000. <strong>Add rule 1</strong> sets the MONTH
field to September, since adding 13 months to August gives September of the next year. Since DAY_OF_MONTH
cannot be 31 in September in a GregorianCalendar
, <strong>add rule 2</strong> sets the DAY_OF_MONTH
to 30, the closest possible value. Although it is a smaller field, DAY_OF_WEEK
is not adjusted by rule 2, since it is expected to change when the month changes in a GregorianCalendar
.
<strong>roll(f, delta)
</strong> adds delta
to field f
without changing larger fields. This is equivalent to calling add(f, delta)
with the following adjustment:
<blockquote>
<strong>Roll rule</strong>. Larger fields are unchanged after the call. A larger field represents a larger unit of time. DAY_OF_MONTH
is a larger field than HOUR
.
</blockquote>
<em>Example</em>: Consider a GregorianCalendar
originally set to August 31, 1999. Calling roll(Calendar.MONTH, 8)
sets the calendar to April 30, <strong>1999</strong>. Add rule 1 sets the MONTH
field to April. Using a GregorianCalendar
, the DAY_OF_MONTH
cannot be 31 in the month April. Add rule 2 sets it to the closest possible value, 30. Finally, the <strong>roll rule</strong> maintains the YEAR
field value of 1999.
<em>Example</em>: Consider a GregorianCalendar
originally set to Sunday June 6, 1999. Calling roll(Calendar.WEEK_OF_MONTH, -1)
sets the calendar to Tuesday June 1, 1999, whereas calling add(Calendar.WEEK_OF_MONTH, -1)
sets the calendar to Sunday May 30, 1999. This is because the roll rule imposes an additional constraint: The MONTH
must not change when the WEEK_OF_MONTH
is rolled. Taken together with add rule 1, the resultant date must be between Tuesday June 1 and Saturday June 5. According to add rule 2, the DAY_OF_WEEK
, an invariant when changing the WEEK_OF_MONTH
, is set to Tuesday, the closest possible value to Sunday (where Sunday is the first day of the week).
<strong>Usage model</strong>. To motivate the behavior of add()
and roll()
, consider a user interface component with increment and decrement buttons for the month, day, and year, and an underlying GregorianCalendar
. If the interface reads January 31, 1999 and the user presses the month increment button, what should it read? If the underlying implementation uses set()
, it might read March 3, 1999. A better result would be February 28, 1999. Furthermore, if the user presses the month increment button again, it should read March 31, 1999, not March 28, 1999. By saving the original date and using either add()
or roll()
, depending on whether larger fields should be affected, the user interface can behave as most users will intuitively expect.
<b>Note:</b> You should always use #roll roll
and #add add
rather than attempting to perform arithmetic operations directly on the fields of a Calendar
. It is quite possible for Calendar
subclasses to have fields with non-linear behavior, for example missing months or days during non-leap years. The subclasses' add
and roll
methods will take this into account, while simple arithmetic manipulations may give invalid results.
<big><big><b>Calendar Architecture in ICU4J</b></big></big>
Recently the implementation of Calendar
has changed significantly in order to better support subclassing. The original Calendar
class was designed to support subclassing, but it had only one implemented subclass, GregorianCalendar
. With the implementation of several new calendar subclasses, including the BuddhistCalendar
, ChineseCalendar
, HebrewCalendar
, IslamicCalendar
, and JapaneseCalendar
, the subclassing API has been reworked thoroughly. This section details the new subclassing API and other ways in which android.icu.util.Calendar
differs from java.util.Calendar
.
<big><b>Changes</b></big>
Overview of changes between the classic Calendar
architecture and the new architecture.
<ul>
<li>The fields[]
array is private
now instead of protected
. Subclasses must access it using the methods #internalSet
and #internalGet
. <b>Motivation:</b> Subclasses should not directly access data members.</li>
<li>The time
long word is private
now instead of protected
. Subclasses may access it using the method #internalGetTimeInMillis
, which does not provoke an update. <b>Motivation:</b> Subclasses should not directly access data members.</li>
<li>The scope of responsibility of subclasses has been drastically reduced. As much functionality as possible is implemented in the Calendar
base class. As a result, it is much easier to subclass Calendar
. <b>Motivation:</b> Subclasses should not have to reimplement common code. Certain behaviors are common across calendar systems: The definition and behavior of week-related fields and time fields, the arithmetic (#add(int, int) add
and #roll(int, int) roll
) behavior of many fields, and the field validation system.</li>
<li>The subclassing API has been completely redesigned.</li>
<li>The Calendar
base class contains some Gregorian calendar algorithmic support that subclasses can use (specifically in #handleComputeFields
). Subclasses can use the methods getGregorianXxx()
to obtain precomputed values. <b>Motivation:</b> This is required by all Calendar
subclasses in order to implement consistent time zone behavior, and Gregorian-derived systems can use the already computed data.</li>
<li>The FIELD_COUNT
constant has been removed. Use #getFieldCount
. In addition, framework API has been added to allow subclasses to define additional fields. <b>Motivation: </b>The number of fields is not constant across calendar systems.</li>
<li>The range of handled dates has been narrowed from +/- ~300,000,000 years to +/- ~5,000,000 years. In practical terms this should not affect clients. However, it does mean that client code cannot be guaranteed well-behaved results with dates such as Date(Long.MIN_VALUE)
or Date(Long.MAX_VALUE)
. Instead, the Calendar
protected constants should be used. <b>Motivation:</b> With the addition of the #JULIAN_DAY
field, Julian day numbers must be restricted to a 32-bit int
. This restricts the overall supported range. Furthermore, restricting the supported range simplifies the computations by removing special case code that was used to accommodate arithmetic overflow at millis near Long.MIN_VALUE
and Long.MAX_VALUE
.</li>
<li>New fields are implemented: #JULIAN_DAY
defines single-field specification of the date. #MILLISECONDS_IN_DAY
defines a single-field specification of the wall time. #DOW_LOCAL
and #YEAR_WOY
implement localized day-of-week and week-of-year behavior.</li>
<li>Subclasses can access protected millisecond constants defined in Calendar
.</li>
<li>New API has been added to support calendar-specific subclasses of DateFormat
.</li>
<li>Several subclasses have been implemented, representing various international calendar systems.</li>
</ul>
<big><b>Subclass API</b></big>
The original Calendar
API was based on the experience of implementing a only a single subclass, GregorianCalendar
. As a result, all of the subclassing kinks had not been worked out. The new subclassing API has been refined based on several implemented subclasses. This includes methods that must be overridden and methods for subclasses to call. Subclasses no longer have direct access to fields
and stamp
. Instead, they have new API to access these. Subclasses are able to allocate the fields
array through a protected framework method; this allows subclasses to specify additional fields.
More functionality has been moved into the base class. The base class now contains much of the computational machinery to support the Gregorian calendar. This is based on two things: (1) Many calendars are based on the Gregorian calendar (such as the Buddhist and Japanese imperial calendars). (2) <em>All</em> calendars require basic Gregorian support in order to handle timezone computations.
Common computations have been moved into Calendar
. Subclasses no longer compute the week related fields and the time related fields. These are commonly handled for all calendars by the base class.
<b>Subclass computation of time =>
fields</b>
The #ERA
, #YEAR
, #EXTENDED_YEAR
, #MONTH
, #DAY_OF_MONTH
, and #DAY_OF_YEAR
fields are computed by the subclass, based on the Julian day. All other fields are computed by Calendar
.
<ul>
<li>Subclasses should implement #handleComputeFields
to compute the #ERA
, #YEAR
, #EXTENDED_YEAR
, #MONTH
, #DAY_OF_MONTH
, and #DAY_OF_YEAR
fields, based on the value of the #JULIAN_DAY
field. If there are calendar-specific fields not defined by Calendar
, they must also be computed. These are the only fields that the subclass should compute. All other fields are computed by the base class, so time and week fields behave in a consistent way across all calendars. The default version of this method in Calendar
implements a proleptic Gregorian calendar. Within this method, subclasses may call getGregorianXxx()
to obtain the Gregorian calendar month, day of month, and extended year for the given date.</li>
</ul>
<b>Subclass computation of fields =>
time</b>
The interpretation of most field values is handled entirely by Calendar
. Calendar
determines which fields are set, which are not, which are set more recently, and so on. In addition, Calendar
handles the computation of the time from the time fields and handles the week-related fields. The only thing the subclass must do is determine the extended year, based on the year fields, and then, given an extended year and a month, it must return a Julian day number.
<ul>
<li>Subclasses should implement #handleGetExtendedYear
to return the extended year for this calendar system, based on the #YEAR
, #EXTENDED_YEAR
, and any fields that the calendar system uses that are larger than a year, such as #ERA
.</li>
<li>Subclasses should implement #handleComputeMonthStart
to return the Julian day number associated with a month and extended year. This is the Julian day number of the day before the first day of the month. The month number is zero-based. This computation should not depend on any field values.</li>
</ul>
<b>Other methods</b>
<ul>
<li>Subclasses should implement #handleGetMonthLength
to return the number of days in a given month of a given extended year. The month number, as always, is zero-based.</li>
<li>Subclasses should implement #handleGetYearLength
to return the number of days in the given extended year. This method is used by computeWeekFields
to compute the #WEEK_OF_YEAR
and #YEAR_WOY
fields.</li>
<li>Subclasses should implement #handleGetLimit
to return the protected values of a field, depending on the value of limitType
. This method only needs to handle the fields #ERA
, #YEAR
, #MONTH
, #WEEK_OF_YEAR
, #WEEK_OF_MONTH
, #DAY_OF_MONTH
, #DAY_OF_YEAR
, #DAY_OF_WEEK_IN_MONTH
, #YEAR_WOY
, and #EXTENDED_YEAR
. Other fields are invariant (with respect to calendar system) and are handled by the base class.</li>
<li>Optionally, subclasses may override #validateField
to check any subclass-specific fields. If the field's value is out of range, the method should throw an IllegalArgumentException
. The method may call super.validateField(field)
to handle fields in a generic way, that is, to compare them to the range getMinimum(field)
..getMaximum(field)
.</li>
<li>Optionally, subclasses may override #handleCreateFields
to create an int[]
array large enough to hold the calendar's fields. This is only necessary if the calendar defines additional fields beyond those defined by Calendar
. The length of the result must be be between the base and maximum field counts.</li>
<li>Optionally, subclasses may override #handleGetDateFormat
to create a DateFormat
appropriate to this calendar. This is only required if a calendar subclass redefines the use of a field (for example, changes the #ERA
field from a symbolic field to a numeric one) or defines an additional field.</li>
<li>Optionally, subclasses may override #roll roll
and #add add
to handle fields that are discontinuous. For example, in the Hebrew calendar the month "Adar I" only occurs in leap years; in other years the calendar jumps from Shevat (month #4) to Adar (month #6). The HebrewCalendar#add HebrewCalendar.add
and HebrewCalendar#roll HebrewCalendar.roll
methods take this into account, so that adding 1 month to Shevat gives the proper result (Adar) in a non-leap year. The protected utility method #pinField pinField
is often useful when implementing these two methods. </li>
</ul>
<big><b>Normalized behavior</b></big>
The behavior of certain fields has been made consistent across all calendar systems and implemented in Calendar
.
<ul>
<li>Time is normalized. Even though some calendar systems transition between days at sunset or at other times, all ICU4J calendars transition between days at <em>local zone midnight</em>. This allows ICU4J to centralize the time computations in Calendar
and to maintain basic correspondences between calendar systems. Affected fields: #AM_PM
, #HOUR
, #HOUR_OF_DAY
, #MINUTE
, #SECOND
, #MILLISECOND
, #ZONE_OFFSET
, and #DST_OFFSET
.</li>
<li>DST behavior is normalized. Daylight savings time behavior is computed the same for all calendar systems, and depends on the value of several GregorianCalendar
fields: the #YEAR
, #MONTH
, and #DAY_OF_MONTH
. As a result, Calendar
always computes these fields, even for non-Gregorian calendar systems. These fields are available to subclasses.</li>
<li>Weeks are normalized. Although locales define the week differently, in terms of the day on which it starts, and the designation of week number one of a month or year, they all use a common mechanism. Furthermore, the day of the week has a simple and consistent definition throughout history. For example, although the Gregorian calendar introduced a discontinuity when first instituted, the day of week was not disrupted. For this reason, the fields #DAY_OF_WEEK
, WEEK_OF_YEAR, WEEK_OF_MONTH
, #DAY_OF_WEEK_IN_MONTH
, #DOW_LOCAL
, #YEAR_WOY
are all computed in a consistent way in the base class, based on the #EXTENDED_YEAR
, #DAY_OF_YEAR
, #MONTH
, and #DAY_OF_MONTH
, which are computed by the subclass.</li>
</ul>
<big><b>Supported range</b></big>
The allowable range of Calendar
has been narrowed. GregorianCalendar
used to attempt to support the range of dates with millisecond values from Long.MIN_VALUE
to Long.MAX_VALUE
. This introduced awkward constructions (hacks) which slowed down performance. It also introduced non-uniform behavior at the boundaries. The new Calendar
protocol specifies the maximum range of supportable dates as those having Julian day numbers of -0x7F000000
to +0x7F000000
. This corresponds to years from ~5,800,000 BCE to ~5,800,000 CE. Programmers should use the protected constants in Calendar
to specify an extremely early or extremely late date.
<big><b>General notes</b></big>
<ul>
<li>Calendars implementations are <em>proleptic</em>. For example, even though the Gregorian calendar was not instituted until the 16th century, the GregorianCalendar
class supports dates before the historical onset of the calendar by extending the calendar system backward in time. Similarly, the HebrewCalendar
extends backward before the start of its epoch into zero and negative years. Subclasses do not throw exceptions because a date precedes the historical start of a calendar system. Instead, they implement #handleGetLimit
to return appropriate limits on #YEAR
, #ERA
, etc. fields. Then, if the calendar is set to not be lenient, out-of-range field values will trigger an exception.</li>
<li>Calendar system subclasses compute a <em>extended year</em>. This differs from the #YEAR
field in that it ranges over all integer values, including zero and negative values, and it encapsulates the information of the #YEAR
field and all larger fields. Thus, for the Gregorian calendar, the #EXTENDED_YEAR
is computed as ERA==AD ? YEAR : 1-YEAR
. Another example is the Mayan long count, which has years (KUN
) and nested cycles of years (KATUN
and BAKTUN
). The Mayan #EXTENDED_YEAR
is computed as TUN + 20 * (KATUN + 20 * BAKTUN)
. The Calendar
base class uses the #EXTENDED_YEAR
field to compute the week-related fields.</li>
</ul>
Java documentation for android.icu.util.Calendar
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
Calendar() |
Constructs a Calendar with the default time zone
and the default |
Calendar(IntPtr, JniHandleOwnership) | |
Calendar(TimeZone, Locale) |
Constructs a calendar with the specified time zone and locale. |
Calendar(TimeZone, ULocale) |
Constructs a calendar with the specified time zone and locale. |
Fields
Am |
Value of the |
AmPm |
Obsolete.
Field number for |
April |
Value of the |
August |
Value of the |
BaseFieldCount |
The number of fields defined by this class. |
Date |
Obsolete.
Field number for |
DayOfMonth |
Obsolete.
Field number for |
DayOfWeek |
Obsolete.
Field number for |
DayOfWeekInMonth |
Obsolete.
Field number for |
DayOfYear |
Obsolete.
Field number for |
December |
Value of the |
DowLocal |
Obsolete.
<strong>[icu]</strong> Field number for |
DstOffset |
Obsolete.
Field number for |
EpochJulianDay |
The Julian day of the epoch, that is, January 1, 1970 on the Gregorian calendar. |
Era |
Obsolete.
Field number for |
ExtendedYear |
Obsolete.
<strong>[icu]</strong> Field number for |
February |
Value of the |
Friday |
Value of the |
GreatestMinimum |
Limit type for |
Hour |
Obsolete.
Field number for |
HourOfDay |
Obsolete.
Field number for |
InternallySet |
Value of the time stamp |
IsLeapMonth |
<strong>[icu]</strong> Field indicating whether or not the current month is a leap month. |
Jan11JulianDay |
The Julian day of the Gregorian epoch, that is, January 1, 1 on the Gregorian calendar. |
January |
Value of the |
JulianDay |
Obsolete.
<strong>[icu]</strong> Field number for |
July |
Value of the |
June |
Value of the |
LeastMaximum |
Limit type for |
March |
Value of the |
MaxFieldCount |
The maximum number of fields possible. |
Maximum |
Limit type for |
MaxJulian |
The maximum supported Julian day. |
MaxMillis |
The maximum supported epoch milliseconds. |
May |
Value of the |
Millisecond |
Obsolete.
Field number for |
MillisecondsInDay |
Obsolete.
<strong>[icu]</strong> Field number for |
Minimum |
Limit type for |
MinimumUserStamp |
If the time stamp |
MinJulian |
The minimum supported Julian day. |
MinMillis |
The minimum supported epoch milliseconds. |
Minute |
Obsolete.
Field number for |
Monday |
Value of the |
Month |
Obsolete.
Field number for |
November |
Value of the |
October |
Value of the |
OneDay |
The number of milliseconds in one day. |
OneHour |
The number of milliseconds in one hour. |
OneMinute |
The number of milliseconds in one minute. |
OneSecond |
The number of milliseconds in one second. |
OneWeek |
The number of milliseconds in one week. |
Pm |
Value of the |
ResolveRemap |
Value to OR against resolve table field values for remapping. |
Saturday |
Value of the |
Second |
Obsolete.
Field number for |
September |
Value of the |
Sunday |
Value of the |
Thursday |
Value of the |
Tuesday |
Value of the |
Undecimber |
Value of the |
Unset |
Value of the time stamp |
WalltimeFirst |
Obsolete.
<strong>[icu]</strong>Option used by |
WalltimeLast |
Obsolete.
<strong>[icu]</strong>Option used by |
WalltimeNextValid |
Obsolete.
<strong>[icu]</strong>Option used by |
Wednesday |
Value of the |
WeekOfMonth |
Obsolete.
Field number for |
WeekOfYear |
Obsolete.
Field number for |
Year |
Obsolete.
Field number for |
YearWoy |
Obsolete.
<strong>[icu]</strong> Field number for |
ZoneOffset |
Obsolete.
Field number for |
Properties
Class |
Returns the runtime class of this |
FieldCount |
<strong>[icu]</strong> Returns the number of fields defined by this calendar. |
FirstDayOfWeek |
Returns what the first day of the week is,
where 1 = |
GregorianDayOfMonth |
Returns the day of month (1-based) on the Gregorian calendar as
computed by |
GregorianDayOfYear |
Returns the day of year (1-based) on the Gregorian calendar as
computed by |
GregorianMonth |
Returns the month (0-based) on the Gregorian calendar as computed by
|
GregorianYear |
Returns the extended year on the Gregorian calendar as computed by
|
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
Instance |
Returns a calendar using the default time zone and locale. |
IsWeekend |
<strong>[icu]</strong> Returns true if this Calendar's current date and time is in the weekend in this calendar system. |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
Lenient |
Tell whether date/time interpretation is to be lenient. -or- Specify whether or not date/time interpretation is to be lenient. |
MaxDate |
The maximum supported |
MinDate |
The minimum supported |
MinimalDaysInFirstWeek |
Returns what the minimal days required in the first week of the year are. -or- Sets what the minimal days required in the first week of the year are. |
PeerReference | (Inherited from Object) |
RepeatedWallTimeOption |
<strong>[icu]</strong>Gets the behavior for handling wall time repeating multiple times at negative time zone offset transitions. -or- <strong>[icu]</strong>Sets the behavior for handling wall time repeating multiple times at negative time zone offset transitions. |
SkippedWallTimeOption |
<strong>[icu]</strong>Gets the behavior for handling skipped wall time at positive time zone offset transitions. -or- <strong>[icu]</strong>Sets the behavior for handling skipped wall time at positive time zone offset transitions. |
ThresholdClass | |
ThresholdType | |
Time |
Returns this Calendar's current time. -or- Sets this Calendar's current time with the given Date. |
TimeInMillis |
Returns this Calendar's current time as a long. -or- Sets this Calendar's current time from the given long value. |
TimeZone |
Returns the time zone. -or- Sets the time zone with the given time zone value. |
Type |
<strong>[icu]</strong> Returns the calendar type name string for this Calendar object. |
Methods
Add(CalendarField, Int32) |
Add a signed amount to a specified field, using this calendar's rules. |
After(Object) |
Compares the time field records. |
Before(Object) |
Compares the time field records. |
Clear() |
Clears the values of all the time fields. |
Clear(CalendarField) |
Clears the value in the given time field. |
Clone() |
Overrides Cloneable |
CompareTo(Calendar) |
Compares the times (in millis) represented by two
|
Complete() |
Fills in any unset fields in the time field list. |
ComputeFields() |
Converts the current millisecond time value |
ComputeGregorianFields(Int32) |
Compute the Gregorian calendar year, month, and day of month from the Julian day. |
ComputeGregorianMonthStart(Int32, Int32) |
Compute the Julian day of a month of the Gregorian calendar. |
ComputeJulianDay() |
Compute the Julian day number as specified by this calendar's fields. |
ComputeMillisInDay() |
Compute the milliseconds in the day from the fields. |
ComputeTime() |
Converts the current field values in |
ComputeZoneOffset(Int64, Int32) |
This method can assume EXTENDED_YEAR has been set. |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
FieldDifference(Date, CalendarField) |
<strong>[icu]</strong> Returns the difference between the given time and the time this calendar object is set to. |
FieldName(CalendarField) |
Returns a string name for a field, for debugging and exceptions. |
FloorDivide(Int32, Int32, Int32[]) |
Divide two integers, returning the floor of the quotient, and the modulus remainder. |
FloorDivide(Int32, Int32) |
Divide two integers, returning the floor of the quotient. |
FloorDivide(Int64, Int32, Int32[]) |
Divide two integers, returning the floor of the quotient, and the modulus remainder. |
FloorDivide(Int64, Int64) |
Divide two long integers, returning the floor of the quotient. |
Get(CalendarField) |
Returns the value for a given time field. |
GetActualMaximum(CalendarField) |
Returns the maximum value that this field could have, given the current date. |
GetActualMinimum(CalendarField) |
Returns the minimum value that this field could have, given the current date. |
GetAvailableLocales() |
Returns the list of locales for which Calendars are installed. |
GetDateTimeFormat(DateFormatStyle, Int32, Locale) |
<strong>[icu]</strong> Returns a |
GetDateTimeFormat(DateFormatStyle, Int32, ULocale) |
<strong>[icu]</strong> Returns a |
GetDisplayName(Locale) |
Returns the name of this calendar in the language of the given locale. |
GetDisplayName(ULocale) |
Returns the name of this calendar in the language of the given locale. |
GetFieldResolutionTable() |
Returns the field resolution array for this calendar. |
GetGreatestMinimum(CalendarField) |
Returns the highest minimum value for the given field if varies. |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
GetInstance(Locale) |
Returns a calendar using the default time zone and specified locale. |
GetInstance(TimeZone, Locale) |
Returns a calendar with the specified time zone and locale. |
GetInstance(TimeZone, ULocale) |
Returns a calendar with the specified time zone and locale. |
GetInstance(TimeZone) |
Returns a calendar using the specified time zone and default locale. |
GetInstance(ULocale) |
Returns a calendar using the default time zone and specified locale. |
GetKeywordValuesForLocale(String, ULocale, Boolean) |
<strong>[icu]</strong> Given a key and a locale, returns an array of string values in a preferred order that would make a difference. |
GetLeastMaximum(CalendarField) |
Returns the lowest maximum value for the given field if varies. |
GetLimit(CalendarField, Int32) |
Returns a limit for a field. |
GetMaximum(CalendarField) |
Returns the maximum value for the given time field. |
GetMinimum(CalendarField) |
Returns the minimum value for the given time field. |
GetStamp(CalendarField) |
Returns the timestamp of a field. |
GetWeekData() | |
GetWeekDataForRegion(String) | |
GregorianMonthLength(Int32, Int32) |
Returns the length of a month of the Gregorian calendar. |
GregorianPreviousMonthLength(Int32, Int32) |
Returns the length of a previous month of the Gregorian calendar. |
HandleComputeFields(Int32) |
Subclasses may override this method to compute several fields specific to each calendar system. |
HandleComputeJulianDay(Int32) |
Subclasses may override this. |
HandleComputeMonthStart(Int32, Int32, Boolean) |
Returns the Julian day number of day before the first day of the given month in the given extended year. |
HandleCreateFields() |
Subclasses that use additional fields beyond those defined in
|
HandleGetDateFormat(String, Locale) |
Creates a |
HandleGetDateFormat(String, String, Locale) |
Creates a |
HandleGetDateFormat(String, ULocale) |
Creates a |
HandleGetExtendedYear() |
Returns the extended year defined by the current fields. |
HandleGetLimit(CalendarField, Int32) |
Subclass API for defining limits of different types. |
HandleGetMonthLength(Int32, Int32) |
Returns the number of days in the given month of the given extended year of this calendar system. |
HandleGetYearLength(Int32) |
Returns the number of days in the given extended year of this calendar system. |
InternalGet(CalendarField, Int32) |
Returns the value for a given time field, or return the given default value if the field is not set. |
InternalGet(CalendarField) |
Returns the value for a given time field. |
InternalGetTimeInMillis() |
Returns the current milliseconds without recomputing. |
InternalSet(CalendarField, Int32) |
Set a field to a value. |
InvokeIsWeekend(Date) |
<strong>[icu]</strong> Returns true if the given date and time is in the weekend in this calendar system. |
IsEquivalentTo(Calendar) |
<strong>[icu]</strong> Returns true if the given Calendar object is equivalent to this one. |
IsGregorianLeapYear(Int32) |
Determines if the given year is a leap year. |
IsSet(CalendarField) |
Determines if the given time field has a value set. |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
JulianDayToDayOfWeek(Int32) |
Returns the day of week, from SUNDAY to SATURDAY, given a Julian day. |
JulianDayToMillis(Int32) |
Converts Julian day to time as milliseconds. |
MillisToJulianDay(Int64) |
Converts time as milliseconds to Julian day. |
NewerField(Int32, Int32) |
Returns the field that is newer, either defaultField, or alternateField. |
NewestStamp(Int32, Int32, Int32) |
Returns the newest stamp of a given range of fields. |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
PinField(CalendarField) |
Adjust the specified field so that it is within the allowable range for the date to which this calendar is set. |
PrepareGetActual(CalendarField, Boolean) |
Prepare this calendar for computing the actual minimum or maximum. |
ResolveFields(Int32[][][]) |
Given a precedence table, return the newest field combination in the table, or -1 if none is found. |
Roll(CalendarField, Boolean) |
Rolls (up/down) a single unit of time on the given field. |
Roll(CalendarField, Int32) |
Rolls (up/down) a specified amount time on the given field. |
Set(CalendarField, Int32) |
Sets the time field with the given value. |
Set(Int32, Int32, Int32, Int32, Int32, Int32) |
Sets the values for the fields year, month, date, hour, minute, and second. |
Set(Int32, Int32, Int32, Int32, Int32) |
Sets the values for the fields year, month, date, hour, and minute. |
Set(Int32, Int32, Int32) |
Sets the values for the fields year, month, and date. |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
SetWeekData(Calendar+WeekData) | |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
ValidateField(CalendarField, Int32, Int32) |
Validate a single field of this calendar given its minimum and maximum allowed value. |
ValidateField(CalendarField) |
Validate a single field of this calendar. |
ValidateFields() |
Ensure that each field is within its valid range by calling |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
WeekNumber(Int32, Int32, Int32) |
Returns the week number of a day, within a period. |
WeekNumber(Int32, Int32) |
Returns the week number of a day, within a period. |
Explicit Interface Implementations
IComparable.CompareTo(Object) | |
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |