3624N/A * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * (C) Copyright Taligent, Inc. 1996-1998 - All Rights Reserved 0N/A * (C) Copyright IBM Corp. 1996-1998 - All Rights Reserved 0N/A * The original version of this source code and documentation is copyrighted 0N/A * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These 0N/A * materials are provided under terms of a License Agreement between Taligent 0N/A * and Sun. This technology is protected by multiple US and International 0N/A * patents. This notice and attribution to Taligent may not be removed. 0N/A * Taligent is a registered trademark of Taligent, Inc. 0N/A * The <code>Calendar</code> class is an abstract class that provides methods 0N/A * for converting between a specific instant in time and a set of {@link 0N/A * #fields calendar fields} such as <code>YEAR</code>, <code>MONTH</code>, 0N/A * <code>DAY_OF_MONTH</code>, <code>HOUR</code>, and so on, and for 0N/A * manipulating the calendar fields, such as getting the date of the next 0N/A * week. An instant in time can be represented by a millisecond value that is 0N/A * an offset from the <a name="Epoch"><em>Epoch</em></a>, January 1, 1970 0N/A * 00:00:00.000 GMT (Gregorian). 0N/A * <p>The class also provides additional fields and methods for 0N/A * implementing a concrete calendar system outside the package. Those 0N/A * fields and methods are defined as <code>protected</code>. 0N/A * Like other locale-sensitive classes, <code>Calendar</code> provides a 0N/A * class method, <code>getInstance</code>, for getting a generally useful 0N/A * object of this type. <code>Calendar</code>'s <code>getInstance</code> method 0N/A * returns a <code>Calendar</code> object whose 0N/A * calendar fields have been initialized with the current date and time: 0N/A * Calendar rightNow = Calendar.getInstance(); 0N/A * <p>A <code>Calendar</code> object can produce all the calendar field values 0N/A * needed to implement the date-time formatting for a particular language and 0N/A * calendar style (for example, Japanese-Gregorian, Japanese-Traditional). 0N/A * <code>Calendar</code> defines the range of values returned by 0N/A * certain calendar fields, as well as their meaning. For example, 0N/A * the first month of the calendar system has value <code>MONTH == 0N/A * JANUARY</code> for all calendars. Other values are defined by the 0N/A * concrete subclass, such as <code>ERA</code>. See individual field 0N/A * documentation and subclass documentation for details. 0N/A * <h4>Getting and Setting Calendar Field Values</h4> 0N/A * <p>The calendar field values can be set by calling the <code>set</code> 0N/A * methods. Any field values set in a <code>Calendar</code> will not be 0N/A * interpreted until it needs to calculate its time value (milliseconds from 0N/A * the Epoch) or values of the calendar fields. Calling the 0N/A * <code>get</code>, <code>getTimeInMillis</code>, <code>getTime</code>, 0N/A * <code>add</code> and <code>roll</code> involves such calculation. 0N/A * <p><code>Calendar</code> has two modes for interpreting the calendar 0N/A * fields, <em>lenient</em> and <em>non-lenient</em>. When a 0N/A * <code>Calendar</code> is in lenient mode, it accepts a wider range of 0N/A * calendar field values than it produces. When a <code>Calendar</code> 0N/A * recomputes calendar field values for return by <code>get()</code>, all of 0N/A * the calendar fields are normalized. For example, a lenient 0N/A * <code>GregorianCalendar</code> interprets <code>MONTH == JANUARY</code>, 0N/A * <code>DAY_OF_MONTH == 32</code> as February 1. 0N/A * <p>When a <code>Calendar</code> is in non-lenient mode, it throws an 0N/A * exception if there is any inconsistency in its calendar fields. For 0N/A * example, a <code>GregorianCalendar</code> always produces 0N/A * <code>DAY_OF_MONTH</code> values between 1 and the length of the month. A 0N/A * non-lenient <code>GregorianCalendar</code> throws an exception upon 0N/A * calculating its time or calendar field values if any out-of-range field 0N/A * value has been set. 2702N/A * <h4><a name="first_week">First Week</a></h4> 0N/A * <code>Calendar</code> defines a locale-specific seven day week using two 0N/A * parameters: the first day of the week and the minimal days in first week 0N/A * (from 1 to 7). These numbers are taken from the locale resource data when a 0N/A * <code>Calendar</code> is constructed. They may also be specified explicitly 0N/A * through the methods for setting their values. 0N/A * <p>When setting or getting the <code>WEEK_OF_MONTH</code> or 0N/A * <code>WEEK_OF_YEAR</code> fields, <code>Calendar</code> must determine the 0N/A * first week of the month or year as a reference point. The first week of a 0N/A * month or year is defined as the earliest seven day period beginning on 0N/A * <code>getFirstDayOfWeek()</code> and containing at least 0N/A * <code>getMinimalDaysInFirstWeek()</code> days of that month or year. Weeks 0N/A * numbered ..., -1, 0 precede the first week; weeks numbered 2, 3,... follow 0N/A * it. Note that the normalized numbering returned by <code>get()</code> may be 0N/A * different. For example, a specific <code>Calendar</code> subclass may 0N/A * designate the week before week 1 of a year as week <code><i>n</i></code> of 0N/A * the previous year. 0N/A * <h4>Calendar Fields Resolution</h4> 0N/A * When computing a date and time from the calendar fields, there 0N/A * may be insufficient information for the computation (such as only 0N/A * year and month with no day of month), or there may be inconsistent 0N/A * information (such as Tuesday, July 15, 1996 (Gregorian) -- July 15, 0N/A * 1996 is actually a Monday). <code>Calendar</code> will resolve 0N/A * calendar field values to determine the date and time in the 0N/A * <p>If there is any conflict in calendar field values, 0N/A * <code>Calendar</code> gives priorities to calendar fields that have been set 0N/A * more recently. The following are the default combinations of the 0N/A * calendar fields. The most recent combination, as determined by the 0N/A * most recently set single field, will be used. 0N/A * <p><a name="date_resolution">For the date fields</a>: 0N/A * YEAR + MONTH + DAY_OF_MONTH 0N/A * YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK 0N/A * YEAR + MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK 0N/A * YEAR + DAY_OF_YEAR 0N/A * YEAR + DAY_OF_WEEK + WEEK_OF_YEAR 0N/A * </pre></blockquote> 0N/A * <a name="time_resolution">For the time of day fields</a>: 0N/A * </pre></blockquote> 0N/A * <p>If there are any calendar fields whose values haven't been set in the selected 0N/A * field combination, <code>Calendar</code> uses their default values. The default 0N/A * value of each field may vary by concrete calendar systems. For example, in 0N/A * <code>GregorianCalendar</code>, the default of a field is the same as that 0N/A * of the start of the Epoch: i.e., <code>YEAR = 1970</code>, <code>MONTH = 0N/A * JANUARY</code>, <code>DAY_OF_MONTH = 1</code>, etc. 0N/A * <strong>Note:</strong> There are certain possible ambiguities in 0N/A * interpretation of certain singular times, which are resolved in the 0N/A * <li> 23:59 is the last minute of the day and 00:00 is the first 0N/A * minute of the next day. Thus, 23:59 on Dec 31, 1999 < 00:00 on 0N/A * Jan 1, 2000 < 00:01 on Jan 1, 2000. 0N/A * <li> Although historically not precise, midnight also belongs to "am", 0N/A * and noon belongs to "pm", so on the same day, 0N/A * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm 0N/A * The date or time format strings are not part of the definition of a 0N/A * calendar, as those must be modifiable or overridable by the user at 0N/A * runtime. Use {@link DateFormat} 0N/A * <h4>Field Manipulation</h4> 0N/A * The calendar fields can be changed using three methods: 0N/A * <code>set()</code>, <code>add()</code>, and <code>roll()</code>.</p> 0N/A * <p><strong><code>set(f, value)</code></strong> changes calendar field 0N/A * <code>f</code> to <code>value</code>. In addition, it sets an 0N/A * internal member variable to indicate that calendar field <code>f</code> has 0N/A * been changed. Although calendar field <code>f</code> is changed immediately, 0N/A * the calendar's time value in milliseconds is not recomputed until the next call to 0N/A * <code>get()</code>, <code>getTime()</code>, <code>getTimeInMillis()</code>, 0N/A * <code>add()</code>, or <code>roll()</code> is made. Thus, multiple calls to 0N/A * <code>set()</code> do not trigger multiple, unnecessary 0N/A * computations. As a result of changing a calendar field using 0N/A * <code>set()</code>, other calendar fields may also change, depending on the 0N/A * calendar field, the calendar field value, and the calendar system. In addition, 0N/A * <code>get(f)</code> will not necessarily return <code>value</code> set by 0N/A * the call to the <code>set</code> method 0N/A * after the calendar fields have been recomputed. The specifics are determined by 0N/A * the concrete calendar class.</p> 0N/A * <p><em>Example</em>: Consider a <code>GregorianCalendar</code> 0N/A * originally set to August 31, 1999. Calling <code>set(Calendar.MONTH, 0N/A * Calendar.SEPTEMBER)</code> sets the date to September 31, 0N/A * 1999. This is a temporary internal representation that resolves to 0N/A * October 1, 1999 if <code>getTime()</code>is then called. However, a 0N/A * call to <code>set(Calendar.DAY_OF_MONTH, 30)</code> before the call to 0N/A * <code>getTime()</code> sets the date to September 30, 1999, since 0N/A * no recomputation occurs after <code>set()</code> itself.</p> 0N/A * <p><strong><code>add(f, delta)</code></strong> adds <code>delta</code> 0N/A * to field <code>f</code>. This is equivalent to calling <code>set(f, 0N/A * get(f) + delta)</code> with two adjustments:</p> 0N/A * <p><strong>Add rule 1</strong>. The value of field <code>f</code> 0N/A * after the call minus the value of field <code>f</code> before the 0N/A * call is <code>delta</code>, modulo any overflow that has occurred in 0N/A * field <code>f</code>. Overflow occurs when a field value exceeds its 0N/A * range and, as a result, the next larger field is incremented or 0N/A * decremented and the field value is adjusted back into its range.</p> 0N/A * <p><strong>Add rule 2</strong>. If a smaller field is expected to be 0N/A * invariant, but it is impossible for it to be equal to its 0N/A * prior value because of changes in its minimum or maximum after field 0N/A * <code>f</code> is changed or other constraints, such as time zone 0N/A * offset changes, then its value is adjusted to be as close 0N/A * as possible to its expected value. A smaller field represents a 0N/A * smaller unit of time. <code>HOUR</code> is a smaller field than 0N/A * <code>DAY_OF_MONTH</code>. No adjustment is made to smaller fields 0N/A * that are not expected to be invariant. The calendar system 0N/A * determines what fields are expected to be invariant.</p> 0N/A * <p>In addition, unlike <code>set()</code>, <code>add()</code> forces 0N/A * an immediate recomputation of the calendar's milliseconds and all 0N/A * <p><em>Example</em>: Consider a <code>GregorianCalendar</code> 0N/A * originally set to August 31, 1999. Calling <code>add(Calendar.MONTH, 0N/A * 13)</code> sets the calendar to September 30, 2000. <strong>Add rule 0N/A * 1</strong> sets the <code>MONTH</code> field to September, since 0N/A * adding 13 months to August gives September of the next year. Since 0N/A * <code>DAY_OF_MONTH</code> cannot be 31 in September in a 0N/A * <code>GregorianCalendar</code>, <strong>add rule 2</strong> sets the 0N/A * <code>DAY_OF_MONTH</code> to 30, the closest possible value. Although 0N/A * it is a smaller field, <code>DAY_OF_WEEK</code> is not adjusted by 0N/A * rule 2, since it is expected to change when the month changes in a 0N/A * <code>GregorianCalendar</code>.</p> 0N/A * <p><strong><code>roll(f, delta)</code></strong> adds 0N/A * <code>delta</code> to field <code>f</code> without changing larger 0N/A * fields. This is equivalent to calling <code>add(f, delta)</code> with 0N/A * the following adjustment:</p> 0N/A * <p><strong>Roll rule</strong>. Larger fields are unchanged after the 0N/A * call. A larger field represents a larger unit of 0N/A * time. <code>DAY_OF_MONTH</code> is a larger field than 0N/A * <code>HOUR</code>.</p> 0N/A * <p><em>Example</em>: See {@link java.util.GregorianCalendar#roll(int, int)}. 0N/A * <p><strong>Usage model</strong>. To motivate the behavior of 0N/A * <code>add()</code> and <code>roll()</code>, consider a user interface 0N/A * component with increment and decrement buttons for the month, day, and 0N/A * year, and an underlying <code>GregorianCalendar</code>. If the 0N/A * interface reads January 31, 1999 and the user presses the month 0N/A * increment button, what should it read? If the underlying 0N/A * implementation uses <code>set()</code>, it might read March 3, 1999. A 0N/A * better result would be February 28, 1999. Furthermore, if the user 0N/A * presses the month increment button again, it should read March 31, 0N/A * 1999, not March 28, 1999. By saving the original date and using either 0N/A * <code>add()</code> or <code>roll()</code>, depending on whether larger 0N/A * fields should be affected, the user interface can behave as most users 0N/A * will intuitively expect.</p> 0N/A * @see java.lang.System#currentTimeMillis() 0N/A * @see GregorianCalendar 0N/A * @see java.text.DateFormat 0N/A * @author Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu 0N/A // Data flow in Calendar 0N/A // --------------------- 0N/A // The current time is represented in two ways by Calendar: as UTC 0N/A // milliseconds from the epoch (1 January 1970 0:00 UTC), and as local 0N/A // fields such as MONTH, HOUR, AM_PM, etc. It is possible to compute the 0N/A // millis from the fields, and vice versa. The data needed to do this 0N/A // conversion is encapsulated by a TimeZone object owned by the Calendar. 0N/A // The data provided by the TimeZone object may also be overridden if the 0N/A // user sets the ZONE_OFFSET and/or DST_OFFSET fields directly. The class 0N/A // keeps track of what information was most recently set by the caller, and 0N/A // uses that to compute any other information as needed. 0N/A // If the user sets the fields using set(), the data flow is as follows. 0N/A // This is implemented by the Calendar subclass's computeTime() method. 0N/A // During this process, certain fields may be ignored. The disambiguation 0N/A // algorithm for resolving which fields to pay attention to is described 0N/A // in the class documentation. 0N/A // local fields (YEAR, MONTH, DATE, HOUR, MINUTE, etc.) 0N/A // | Using Calendar-specific algorithm 0N/A // local standard millis 0N/A // | Using TimeZone or user-set ZONE_OFFSET / DST_OFFSET 0N/A // UTC millis (in time data member) 0N/A // If the user sets the UTC millis using setTime() or setTimeInMillis(), 0N/A // the data flow is as follows. This is implemented by the Calendar 0N/A // subclass's computeFields() method. 0N/A // UTC millis (in time data member) 0N/A // | Using TimeZone getOffset() 0N/A // local standard millis 0N/A // | Using Calendar-specific algorithm 0N/A // local fields (YEAR, MONTH, DATE, HOUR, MINUTE, etc.) 0N/A // In general, a round trip from fields, through local and UTC millis, and 0N/A // back out to fields is made when necessary. This is implemented by the 0N/A // complete() method. Resolving a partial set of fields into a UTC millis 0N/A // value allows all remaining fields to be generated from that value. If 0N/A // the Calendar is lenient, the fields are also renormalized to standard 0N/A // ranges when they are regenerated. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * era, e.g., AD or BC in the Julian calendar. This is a calendar-specific 0N/A * value; see subclass documentation. 0N/A * @see GregorianCalendar#AD 0N/A * @see GregorianCalendar#BC 0N/A public final static int ERA =
0;
0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * year. This is a calendar-specific value; see subclass documentation. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * month. This is a calendar-specific value. The first month of 0N/A * the year in the Gregorian and Julian calendars is 0N/A * <code>JANUARY</code> which is 0; the last depends on the number 0N/A * of months in a year. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * week number within the current year. The first week of the year, as 0N/A * defined by <code>getFirstDayOfWeek()</code> and 0N/A * <code>getMinimalDaysInFirstWeek()</code>, has value 1. Subclasses define 0N/A * the value of <code>WEEK_OF_YEAR</code> for days before the first week of 0N/A * @see #getFirstDayOfWeek 0N/A * @see #getMinimalDaysInFirstWeek 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * week number within the current month. The first week of the month, as 0N/A * defined by <code>getFirstDayOfWeek()</code> and 0N/A * <code>getMinimalDaysInFirstWeek()</code>, has value 1. Subclasses define 0N/A * the value of <code>WEEK_OF_MONTH</code> for days before the first week of 0N/A * @see #getFirstDayOfWeek 0N/A * @see #getMinimalDaysInFirstWeek 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * day of the month. This is a synonym for <code>DAY_OF_MONTH</code>. 0N/A * The first day of the month has value 1. 0N/A * @see #DAY_OF_MONTH 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * day of the month. This is a synonym for <code>DATE</code>. 0N/A * The first day of the month has value 1. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the day 0N/A * number within the current year. The first day of the year has value 1. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the day 0N/A * of the week. This field takes values <code>SUNDAY</code>, 0N/A * <code>MONDAY</code>, <code>TUESDAY</code>, <code>WEDNESDAY</code>, 0N/A * <code>THURSDAY</code>, <code>FRIDAY</code>, and <code>SATURDAY</code>. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * ordinal number of the day of the week within the current month. Together 0N/A * with the <code>DAY_OF_WEEK</code> field, this uniquely specifies a day 0N/A * within a month. Unlike <code>WEEK_OF_MONTH</code> and 0N/A * <code>WEEK_OF_YEAR</code>, this field's value does <em>not</em> depend on 0N/A * <code>getFirstDayOfWeek()</code> or 0N/A * <code>getMinimalDaysInFirstWeek()</code>. <code>DAY_OF_MONTH 1</code> 0N/A * through <code>7</code> always correspond to <code>DAY_OF_WEEK_IN_MONTH 0N/A * 1</code>; <code>8</code> through <code>14</code> correspond to 0N/A * <code>DAY_OF_WEEK_IN_MONTH 2</code>, and so on. 0N/A * <code>DAY_OF_WEEK_IN_MONTH 0</code> indicates the week before 0N/A * <code>DAY_OF_WEEK_IN_MONTH 1</code>. Negative values count back from the 0N/A * end of the month, so the last Sunday of a month is specified as 0N/A * <code>DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1</code>. Because 0N/A * negative values count backward they will usually be aligned differently 0N/A * within the month than positive values. For example, if a month has 31 0N/A * days, <code>DAY_OF_WEEK_IN_MONTH -1</code> will overlap 0N/A * <code>DAY_OF_WEEK_IN_MONTH 5</code> and the end of <code>4</code>. 0N/A * @see #WEEK_OF_MONTH 0N/A * Field number for <code>get</code> and <code>set</code> indicating 0N/A * whether the <code>HOUR</code> is before or after noon. 0N/A * E.g., at 10:04:15.250 PM the <code>AM_PM</code> is <code>PM</code>. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * hour of the morning or afternoon. <code>HOUR</code> is used for the 0N/A * 12-hour clock (0 - 11). Noon and midnight are represented by 0, not by 12. 0N/A * E.g., at 10:04:15.250 PM the <code>HOUR</code> is 10. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * hour of the day. <code>HOUR_OF_DAY</code> is used for the 24-hour clock. 0N/A * E.g., at 10:04:15.250 PM the <code>HOUR_OF_DAY</code> is 22. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * minute within the hour. 0N/A * E.g., at 10:04:15.250 PM the <code>MINUTE</code> is 4. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * second within the minute. 0N/A * E.g., at 10:04:15.250 PM the <code>SECOND</code> is 15. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 0N/A * millisecond within the second. 0N/A * E.g., at 10:04:15.250 PM the <code>MILLISECOND</code> is 250. 0N/A * Field number for <code>get</code> and <code>set</code> 0N/A * indicating the raw offset from GMT in milliseconds. 0N/A * This field reflects the correct GMT offset value of the time 0N/A * zone of this <code>Calendar</code> if the 0N/A * <code>TimeZone</code> implementation subclass supports 0N/A * historical GMT offset changes. 0N/A * Field number for <code>get</code> and <code>set</code> indicating the 3624N/A * daylight saving offset in milliseconds. 0N/A * This field reflects the correct daylight saving offset value of 0N/A * the time zone of this <code>Calendar</code> if the 0N/A * <code>TimeZone</code> implementation subclass supports 0N/A * historical Daylight Saving Time schedule changes. 0N/A * The number of distinct fields recognized by <code>get</code> and <code>set</code>. 0N/A * Field numbers range from <code>0..FIELD_COUNT-1</code>. 0N/A * Value of the {@link #DAY_OF_WEEK} field indicating 0N/A * Value of the {@link #DAY_OF_WEEK} field indicating 0N/A * Value of the {@link #DAY_OF_WEEK} field indicating 0N/A * Value of the {@link #DAY_OF_WEEK} field indicating 0N/A * Value of the {@link #DAY_OF_WEEK} field indicating 0N/A * Value of the {@link #DAY_OF_WEEK} field indicating 0N/A * Value of the {@link #DAY_OF_WEEK} field indicating 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * first month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * second month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * third month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * fourth month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * fifth month of the year in the Gregorian and Julian calendars. 0N/A public final static int MAY =
4;
0N/A * Value of the {@link #MONTH} field indicating the 0N/A * sixth month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * seventh month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * eighth month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * ninth month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * tenth month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * eleventh month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * twelfth month of the year in the Gregorian and Julian calendars. 0N/A * Value of the {@link #MONTH} field indicating the 0N/A * thirteenth month of the year. Although <code>GregorianCalendar</code> 0N/A * does not use this value, lunar calendars do. 0N/A * Value of the {@link #AM_PM} field indicating the 0N/A * period of the day from midnight to just before noon. 0N/A public final static int AM =
0;
0N/A * Value of the {@link #AM_PM} field indicating the 0N/A * period of the day from noon to just before midnight. 0N/A public final static int PM =
1;
0N/A * A style specifier for {@link #getDisplayNames(int, int, Locale) 0N/A * getDisplayNames} indicating names in all styles, such as 0N/A * "January" and "Jan". 0N/A * A style specifier for {@link #getDisplayName(int, int, Locale) 0N/A * getDisplayName} and {@link #getDisplayNames(int, int, Locale) 0N/A * getDisplayNames} indicating a short name, such as "Jan". 0N/A * A style specifier for {@link #getDisplayName(int, int, Locale) 0N/A * getDisplayName} and {@link #getDisplayNames(int, int, Locale) 0N/A * getDisplayNames} indicating a long name, such as "January". 0N/A // Calendar contains two kinds of time representations: current "time" in 0N/A // milliseconds, and a set of calendar "fields" representing the current time. 0N/A // The two representations are usually in sync, but can get out of sync 0N/A // 1. Initially, no fields are set, and the time is invalid. 0N/A // 2. If the time is set, all fields are computed and in sync. 0N/A // 3. If a single field is set, the time is invalid. 0N/A // Recomputation of the time and fields happens when the object needs 0N/A // to return a result to the user, or use a result for a computation. 0N/A * The calendar field values for the currently set time for this calendar. 0N/A * This is an array of <code>FIELD_COUNT</code> integers, with index values 0N/A * <code>ERA</code> through <code>DST_OFFSET</code>. 0N/A * The flags which tell if a specified calendar field for the calendar is set. 0N/A * A new object has no fields set. After the first call to a method 0N/A * which generates the fields, they all remain set after that. 0N/A * This is an array of <code>FIELD_COUNT</code> booleans, with index values 0N/A * <code>ERA</code> through <code>DST_OFFSET</code>. 0N/A * Pseudo-time-stamps which specify when each field was set. There 0N/A * are two special values, UNSET and COMPUTED. Values from 0N/A * MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values. 0N/A * The currently set time for this calendar, expressed in milliseconds after 0N/A * January 1, 1970, 0:00:00 GMT. 0N/A * True if then the value of <code>time</code> is valid. 0N/A * The time is made invalid by a change to an item of <code>field[]</code>. 0N/A * True if <code>fields[]</code> are in sync with the currently set time. 0N/A * If false, then the next attempt to get the value of a field will 0N/A * force a recomputation of all fields from the current value of 0N/A * <code>time</code>. 0N/A * True if all fields have been set. 0N/A * <code>True</code> if this calendar allows out-of-range field values during computation 0N/A * of <code>time</code> from <code>fields[]</code>. 0N/A * The <code>TimeZone</code> used by this calendar. <code>Calendar</code> 0N/A * uses the time zone data to translate between locale and GMT time. 0N/A * <code>True</code> if zone references to a shared TimeZone object. 0N/A * The first day of the week, with possible values <code>SUNDAY</code>, 0N/A * <code>MONDAY</code>, etc. This is a locale-dependent value. 0N/A * The number of days required for the first week in a month or year, 0N/A * with possible values from 1 to 7. This is a locale-dependent value. 0N/A * Cache to hold the firstDayOfWeek and minimalDaysInFirstWeek 0N/A // Special values of stamp[] 0N/A * The corresponding fields[] has no value. 0N/A * The value of the corresponding fields[] has been calculated internally. 0N/A * The value of the corresponding fields[] has been set externally. Stamp 0N/A * values which are greater than 1 represents the (pseudo) time when the 0N/A * corresponding fields[] value was set. 0N/A * The mask value that represents all of the fields. 0N/A * The next available value for <code>stamp[]</code>, an internal array. 0N/A * This actually should not be written out to the stream, and will probably 0N/A * be removed from the stream in the near future. In the meantime, 0N/A * a value of <code>MINIMUM_USER_STAMP</code> should be used. 0N/A // the internal serial version which says which version was written 0N/A // - 0 (default) for version up to JDK 1.1.5 0N/A // - 1 for version from JDK 1.1.6, which writes a correct 'time' value 0N/A // as well as compatible values for other fields. This is a 0N/A // transitional format. 0N/A // - 2 (not implemented yet) a future version, in which fields[], 0N/A // areFieldsSet, and isTimeSet become transient, and isSet[] is 0N/A // removed. In JDK 1.1.6 we write a format compatible with version 2. 0N/A * The version of the serialized data on the stream. Possible values: 0N/A * <dt><b>0</b> or not present on stream</dt> 0N/A * JDK 1.1.5 or earlier. 0N/A * JDK 1.1.6 or later. Writes a correct 'time' value 0N/A * as well as compatible values for other fields. This is a 0N/A * transitional format. 0N/A * When streaming out this class, the most recent format 0N/A * and the highest allowable <code>serialVersionOnStream</code> 0N/A // Proclaim serialization compatibility with JDK 1.1 0N/A // Mask values for calendar fields 0N/A * Constructs a Calendar with the default time zone 0N/A * @see TimeZone#getDefault 0N/A * Constructs a calendar with the specified time zone and locale. 0N/A * @param zone the time zone to use 0N/A * @param aLocale the locale for the week data 0N/A * Gets a calendar using the default time zone and locale. The 0N/A * <code>Calendar</code> returned is based on the current time 0N/A * in the default time zone with the default locale. 0N/A * @return a Calendar. 0N/A * Gets a calendar using the specified time zone and default locale. 0N/A * The <code>Calendar</code> returned is based on the current time 0N/A * in the given time zone with the default locale. 0N/A * @param zone the time zone to use 0N/A * @return a Calendar. 0N/A * Gets a calendar using the default time zone and specified locale. 0N/A * The <code>Calendar</code> returned is based on the current time 0N/A * in the default time zone with the given locale. 0N/A * @param aLocale the locale for the week data 0N/A * @return a Calendar. 0N/A * Gets a calendar with the specified time zone and locale. 0N/A * The <code>Calendar</code> returned is based on the current time 0N/A * in the given time zone with the given locale. 0N/A * @param zone the time zone to use 0N/A * @param aLocale the locale for the week data 0N/A * @return a Calendar. 2712N/A // Calendar type is not specified. 2712N/A // If the specified locale is a Thai locale, 2712N/A // returns a BuddhistCalendar instance. 2712N/A // Unsupported calendar type. 2712N/A // Use Gregorian calendar as a fallback. 0N/A * Returns an array of all locales for which the <code>getInstance</code> 0N/A * methods of this class can return localized instances. 0N/A * The array returned must contain at least a <code>Locale</code> 0N/A * instance equal to {@link java.util.Locale#US Locale.US}. 0N/A * @return An array of locales for which localized 0N/A * <code>Calendar</code> instances are available. 0N/A * Converts the current calendar field values in {@link #fields fields[]} 0N/A * to the millisecond time value 0N/A * @see #computeFields() 0N/A * Converts the current millisecond time value {@link #time} 0N/A * to calendar field values in {@link #fields fields[]}. 0N/A * This allows you to sync up the calendar field values with 0N/A * a new time that is set for the calendar. The time is <em>not</em> 0N/A * recomputed first; to recompute the time, then the fields, call the 0N/A * {@link #complete()} method. 0N/A * @see #computeTime() 0N/A * Returns a <code>Date</code> object representing this 0N/A * <code>Calendar</code>'s time value (millisecond offset from the <a 0N/A * href="#Epoch">Epoch</a>"). 0N/A * @return a <code>Date</code> representing the time value. 0N/A * @see #setTime(Date) 0N/A * @see #getTimeInMillis() 0N/A * Sets this Calendar's time with the given <code>Date</code>. 0N/A * Note: Calling <code>setTime()</code> with 0N/A * <code>Date(Long.MAX_VALUE)</code> or <code>Date(Long.MIN_VALUE)</code> 0N/A * may yield incorrect field values from <code>get()</code>. 0N/A * @param date the given Date. 0N/A * @see #setTimeInMillis(long) 0N/A * Returns this Calendar's time value in milliseconds. 0N/A * @return the current time as UTC milliseconds from the epoch. 0N/A * @see #setTimeInMillis(long) 0N/A * Sets this Calendar's current time from the given long value. 0N/A * @param millis the new time in UTC milliseconds from the epoch. 0N/A * @see #setTime(Date) 0N/A * @see #getTimeInMillis() 0N/A // If we don't need to recalculate the calendar field values, 0N/A * Returns the value of the given calendar field. In lenient mode, 0N/A * all calendar fields are normalized. In non-lenient mode, all 0N/A * calendar fields are validated and this method throws an 0N/A * exception if any calendar fields have out-of-range values. The 0N/A * normalization and validation are handled by the 0N/A * {@link #complete()} method, which process is calendar 0N/A * @param field the given calendar field. 0N/A * @return the value for the given calendar field. 0N/A * @throws ArrayIndexOutOfBoundsException if the specified field is out of range 0N/A * (<code>field < 0 || field >= FIELD_COUNT</code>). 0N/A * @see #set(int,int) 0N/A * Returns the value of the given calendar field. This method does 0N/A * not involve normalization or validation of the field value. 0N/A * @param field the given calendar field. 0N/A * @return the value for the given calendar field. 0N/A * Sets the value of the given calendar field. This method does 0N/A * not affect any setting state of the field in this 0N/A * <code>Calendar</code> instance. 0N/A * @throws IndexOutOfBoundsException if the specified field is out of range 0N/A * (<code>field < 0 || field >= FIELD_COUNT</code>). 0N/A * @see #areFieldsSet 0N/A * @see #areAllFieldsSet 0N/A * @see #set(int,int) 0N/A * Sets the given calendar field to the given value. The value is not 0N/A * interpreted by this method regardless of the leniency mode. 0N/A * @param field the given calendar field. 0N/A * @param value the value to be set for the given calendar field. 0N/A * @throws ArrayIndexOutOfBoundsException if the specified field is out of range 0N/A * (<code>field < 0 || field >= FIELD_COUNT</code>). 0N/A * in non-lenient mode. 0N/A * @see #set(int,int,int) 0N/A * @see #set(int,int,int,int,int) 0N/A * @see #set(int,int,int,int,int,int) 811N/A // If the fields are partially normalized, calculate all the 811N/A // fields before changing any fields. 0N/A * Sets the values for the calendar fields <code>YEAR</code>, 0N/A * <code>MONTH</code>, and <code>DAY_OF_MONTH</code>. 0N/A * Previous values of other calendar fields are retained. If this is not desired, 0N/A * call {@link #clear()} first. 0N/A * @param year the value used to set the <code>YEAR</code> calendar field. 0N/A * @param month the value used to set the <code>MONTH</code> calendar field. 0N/A * Month value is 0-based. e.g., 0 for January. 0N/A * @param date the value used to set the <code>DAY_OF_MONTH</code> calendar field. 0N/A * @see #set(int,int) 0N/A * @see #set(int,int,int,int,int) 0N/A * @see #set(int,int,int,int,int,int) 0N/A * Sets the values for the calendar fields <code>YEAR</code>, 0N/A * <code>MONTH</code>, <code>DAY_OF_MONTH</code>, 0N/A * <code>HOUR_OF_DAY</code>, and <code>MINUTE</code>. 0N/A * Previous values of other fields are retained. If this is not desired, 0N/A * call {@link #clear()} first. 0N/A * @param year the value used to set the <code>YEAR</code> calendar field. 0N/A * @param month the value used to set the <code>MONTH</code> calendar field. 0N/A * Month value is 0-based. e.g., 0 for January. 0N/A * @param date the value used to set the <code>DAY_OF_MONTH</code> calendar field. 0N/A * @param hourOfDay the value used to set the <code>HOUR_OF_DAY</code> calendar field. 0N/A * @param minute the value used to set the <code>MINUTE</code> calendar field. 0N/A * @see #set(int,int) 0N/A * @see #set(int,int,int) 0N/A * @see #set(int,int,int,int,int,int) 0N/A * Sets the values for the fields <code>YEAR</code>, <code>MONTH</code>, 0N/A * <code>DAY_OF_MONTH</code>, <code>HOUR</code>, <code>MINUTE</code>, and 0N/A * <code>SECOND</code>. 0N/A * Previous values of other fields are retained. If this is not desired, 0N/A * call {@link #clear()} first. 0N/A * @param year the value used to set the <code>YEAR</code> calendar field. 0N/A * @param month the value used to set the <code>MONTH</code> calendar field. 0N/A * Month value is 0-based. e.g., 0 for January. 0N/A * @param date the value used to set the <code>DAY_OF_MONTH</code> calendar field. 0N/A * @param hourOfDay the value used to set the <code>HOUR_OF_DAY</code> calendar field. 0N/A * @param minute the value used to set the <code>MINUTE</code> calendar field. 0N/A * @param second the value used to set the <code>SECOND</code> calendar field. 0N/A * @see #set(int,int) 0N/A * @see #set(int,int,int) 0N/A * @see #set(int,int,int,int,int) 0N/A * Sets all the calendar field values and the time value 0N/A * (millisecond offset from the <a href="#Epoch">Epoch</a>) of 0N/A * this <code>Calendar</code> undefined. This means that {@link 0N/A * #isSet(int) isSet()} will return <code>false</code> for all the 0N/A * calendar fields, and the date and time calculations will treat 0N/A * the fields as if they had never been set. A 0N/A * <code>Calendar</code> implementation class may use its specific 0N/A * default field values for date/time calculations. For example, 0N/A * <code>GregorianCalendar</code> uses 1970 if the 0N/A * <code>YEAR</code> field value is undefined. 0N/A * Sets the given calendar field value and the time value 0N/A * (millisecond offset from the <a href="#Epoch">Epoch</a>) of 0N/A * this <code>Calendar</code> undefined. This means that {@link 0N/A * #isSet(int) isSet(field)} will return <code>false</code>, and 0N/A * the date and time calculations will treat the field as if it 0N/A * had never been set. A <code>Calendar</code> implementation 0N/A * class may use the field's specific default value for date and 0N/A * time calculations. 0N/A * <p>The {@link #HOUR_OF_DAY}, {@link #HOUR} and {@link #AM_PM} 0N/A * fields are handled independently and the <a 0N/A * href="#time_resolution">the resolution rule for the time of 0N/A * day</a> is applied. Clearing one of the fields doesn't reset 0N/A * the hour of day value of this <code>Calendar</code>. Use {@link 0N/A * #set(int,int) set(Calendar.HOUR_OF_DAY, 0)} to reset the hour 0N/A * @param field the calendar field to be cleared. 0N/A * Determines if the given calendar field has a value set, 0N/A * including cases that the value has been set by internal fields 0N/A * calculations triggered by a <code>get</code> method call. 0N/A * @return <code>true</code> if the given calendar field has a value set; 0N/A * <code>false</code> otherwise. 0N/A * Returns the string representation of the calendar 0N/A * <code>field</code> value in the given <code>style</code> and 0N/A * <code>locale</code>. If no string representation is 0N/A * applicable, <code>null</code> is returned. This method calls 0N/A * {@link Calendar#get(int) get(field)} to get the calendar 0N/A * <code>field</code> value if the string representation is 0N/A * applicable to the given calendar <code>field</code>. 0N/A * <p>For example, if this <code>Calendar</code> is a 0N/A * <code>GregorianCalendar</code> and its date is 2005-01-01, then 0N/A * the string representation of the {@link #MONTH} field would be 0N/A * "January" in the long style in an English locale or "Jan" in 0N/A * the short style. However, no string representation would be 0N/A * available for the {@link #DAY_OF_MONTH} field, and this method 0N/A * would return <code>null</code>. 0N/A * <p>The default implementation supports the calendar fields for 0N/A * which a {@link DateFormatSymbols} has names in the given 0N/A * <code>locale</code>. 0N/A * the calendar field for which the string representation 0N/A * the style applied to the string representation; one of 0N/A * {@link #SHORT} or {@link #LONG}. 0N/A * the locale for the string representation 0N/A * @return the string representation of the given 0N/A * <code>field</code> in the given <code>style</code>, or 0N/A * <code>null</code> if no string representation is 0N/A * @exception IllegalArgumentException 0N/A * if <code>field</code> or <code>style</code> is invalid, 0N/A * or if this <code>Calendar</code> is non-lenient and any 0N/A * of the calendar fields have invalid values 0N/A * @exception NullPointerException 0N/A * if <code>locale</code> is null 0N/A * Returns a <code>Map</code> containing all names of the calendar 0N/A * <code>field</code> in the given <code>style</code> and 0N/A * <code>locale</code> and their corresponding field values. For 0N/A * example, if this <code>Calendar</code> is a {@link 0N/A * GregorianCalendar}, the returned map would contain "Jan" to 0N/A * {@link #JANUARY}, "Feb" to {@link #FEBRUARY}, and so on, in the 0N/A * {@linkplain #SHORT short} style in an English locale. 0N/A * <p>The values of other calendar fields may be taken into 0N/A * account to determine a set of display names. For example, if 0N/A * this <code>Calendar</code> is a lunisolar calendar system and 0N/A * the year value given by the {@link #YEAR} field has a leap 0N/A * month, this method would return month names containing the leap 0N/A * month name, and month names are mapped to their values specific 0N/A * <p>The default implementation supports display names contained in 0N/A * a {@link DateFormatSymbols}. For example, if <code>field</code> 0N/A * is {@link #MONTH} and <code>style</code> is {@link 0N/A * #ALL_STYLES}, this method returns a <code>Map</code> containing 0N/A * all strings returned by {@link DateFormatSymbols#getShortMonths()} 0N/A * and {@link DateFormatSymbols#getMonths()}. 0N/A * the calendar field for which the display names are returned 0N/A * the style applied to the display names; one of {@link 0N/A * #SHORT}, {@link #LONG}, or {@link #ALL_STYLES}. 0N/A * the locale for the display names 0N/A * @return a <code>Map</code> containing all display names in 0N/A * <code>style</code> and <code>locale</code> and their 0N/A * field values, or <code>null</code> if no display names 0N/A * are defined for <code>field</code> 0N/A * @exception IllegalArgumentException 0N/A * if <code>field</code> or <code>style</code> is invalid, 0N/A * or if this <code>Calendar</code> is non-lenient and any 0N/A * of the calendar fields have invalid values 0N/A * @exception NullPointerException 0N/A * if <code>locale</code> is null 0N/A * Fills in any unset fields in the calendar fields. First, the {@link 0N/A * #computeTime()} method is called if the time value (millisecond offset 0N/A * from the <a href="#Epoch">Epoch</a>) has not been calculated from 0N/A * calendar field values. Then, the {@link #computeFields()} method is 0N/A * called to calculate all calendar field values. 0N/A * Returns whether the value of the specified calendar field has been set 0N/A * externally by calling one of the setter methods rather than by the 0N/A * internal time calculation. 0N/A * @return <code>true</code> if the field has been set externally, 0N/A * <code>false</code> otherwise. 0N/A * @exception IndexOutOfBoundsException if the specified 0N/A * <code>field</code> is out of range 0N/A * (<code>field < 0 || field >= FIELD_COUNT</code>). 0N/A * @see #selectFields() 0N/A * @see #setFieldsComputed(int) 0N/A * Returns a field mask (bit mask) indicating all calendar fields that 0N/A * have the state of externally or internally set. 0N/A * @return a bit mask indicating set state fields 0N/A * Sets the state of the specified calendar fields to 0N/A * <em>computed</em>. This state means that the specified calendar fields 0N/A * have valid values that have been set by internal time calculation 0N/A * rather than by calling one of the setter methods. 0N/A * @param fieldMask the field to be marked as computed. 0N/A * @exception IndexOutOfBoundsException if the specified 0N/A * <code>field</code> is out of range 0N/A * (<code>field < 0 || field >= FIELD_COUNT</code>). 0N/A * @see #isExternallySet(int) 0N/A * @see #selectFields() 0N/A * Sets the state of the calendar fields that are <em>not</em> specified 0N/A * by <code>fieldMask</code> to <em>unset</em>. If <code>fieldMask</code> 0N/A * specifies all the calendar fields, then the state of this 0N/A * <code>Calendar</code> becomes that all the calendar fields are in sync 0N/A * with the time value (millisecond offset from the Epoch). 0N/A * @param fieldMask the field mask indicating which calendar fields are in 0N/A * sync with the time value. 0N/A * @exception IndexOutOfBoundsException if the specified 0N/A * <code>field</code> is out of range 0N/A * (<code>field < 0 || field >= FIELD_COUNT</code>). 0N/A * @see #isExternallySet(int) 0N/A * @see #selectFields() 0N/A // Some or all of the fields are in sync with the 0N/A // milliseconds, but the stamp values are not normalized yet. 0N/A * Returns whether the calendar fields are partially in sync with the time 0N/A * value or fully in sync but not stamp values are not normalized yet. 0N/A * Returns whether the calendar fields are fully in sync with the time 0N/A * Marks this Calendar as not sync'd. 0N/A * Returns whether the specified <code>field</code> is on in the 0N/A * <code>fieldMask</code>. 0N/A * Returns a field mask indicating which calendar field values 0N/A * to be used to calculate the time value. The calendar fields are 0N/A * returned as a bit mask, each bit of which corresponds to a field, i.e., 0N/A * the mask value of <code>field</code> is <code>(1 << 0N/A * field)</code>. For example, 0x26 represents the <code>YEAR</code>, 0N/A * <code>MONTH</code>, and <code>DAY_OF_MONTH</code> fields (i.e., 0x26 is 0N/A * <code>(1<<YEAR)|(1<<MONTH)|(1<<DAY_OF_MONTH))</code>. 0N/A * <p>This method supports the calendar fields resolution as described in 0N/A * the class description. If the bit mask for a given field is on and its 0N/A * field has not been set (i.e., <code>isSet(field)</code> is 0N/A * <code>false</code>), then the default value of the field has to be 0N/A * used, which case means that the field has been selected because the 0N/A * selected combination involves the field. 0N/A * @return a bit mask of selected fields 0N/A * @see #isExternallySet(int) 0N/A * @see #setInternallySetState(int) 0N/A // This implementation has been taken from the GregorianCalendar class. 0N/A // The YEAR field must always be used regardless of its SET 0N/A // state because YEAR is a mandatory field to determine the date 0N/A // and the default value (EPOCH_YEAR) may change through the 0N/A // normalization process. 0N/A // Find the most recent group of fields specifying the day within 0N/A // the year. These may be any of the following combinations: 0N/A // MONTH + DAY_OF_MONTH 0N/A // MONTH + WEEK_OF_MONTH + DAY_OF_WEEK 0N/A // MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK 0N/A // WEEK_OF_YEAR + DAY_OF_WEEK 0N/A // We look for the most recent of the fields in each group to determine 0N/A // the age of the group. For groups involving a week-related field such 0N/A // as WEEK_OF_MONTH, DAY_OF_WEEK_IN_MONTH, or WEEK_OF_YEAR, both the 0N/A // week-related field and the DAY_OF_WEEK must be set for the group as a 0N/A // whole to be considered. (See bug 4153860 - liu 7/24/98.) 0N/A /* No complete combination exists. Look for WEEK_OF_MONTH, 0N/A * DAY_OF_WEEK_IN_MONTH, or WEEK_OF_YEAR alone. Treat DAY_OF_WEEK alone 0N/A * as DAY_OF_WEEK_IN_MONTH. 0N/A /* Treat MONTH alone or no fields at all as DAY_OF_MONTH. This may 0N/A * result in bestStamp = domStamp = UNSET if no fields are set, 0N/A * which indicates DAY_OF_MONTH. 0N/A // When they are equal, give the priority to 0N/A // WEEK_OF_MONTH for compatibility. 0N/A // Find the best set of fields specifying the time of day. There 0N/A // are only two possibilities here; the HOUR_OF_DAY or the 0N/A // AM_PM and the HOUR. 0N/A // if bestStamp is still UNSET, then take HOUR or AM_PM. (See 4846659) 0N/A * Returns the pseudo-time-stamp for two fields, given their 0N/A * individual pseudo-time-stamps. If either of the fields 0N/A * is unset, then the aggregate is unset. Otherwise, the 0N/A * aggregate is the later of the two stamps. 0N/A * Compares this <code>Calendar</code> to the specified 0N/A * <code>Object</code>. The result is <code>true</code> if and only if 0N/A * the argument is a <code>Calendar</code> object of the same calendar 0N/A * system that represents the same time value (millisecond offset from the 0N/A * <a href="#Epoch">Epoch</a>) under the same 0N/A * <code>Calendar</code> parameters as this object. 0N/A * <p>The <code>Calendar</code> parameters are the values represented 0N/A * by the <code>isLenient</code>, <code>getFirstDayOfWeek</code>, 0N/A * <code>getMinimalDaysInFirstWeek</code> and <code>getTimeZone</code> 0N/A * methods. If there is any difference in those parameters 0N/A * between the two <code>Calendar</code>s, this method returns 0N/A * <code>false</code>. 0N/A * <p>Use the {@link #compareTo(Calendar) compareTo} method to 0N/A * compare only the time values. 0N/A * @param obj the object to compare with. 0N/A * @return <code>true</code> if this object is equal to <code>obj</code>; 0N/A * <code>false</code> otherwise. 0N/A // Note: GregorianCalendar.computeTime throws 0N/A // IllegalArgumentException if the ERA value is invalid 0N/A // even it's in lenient mode. 0N/A * Returns a hash code for this calendar. 0N/A * @return a hash code value for this object. 0N/A // 'otheritems' represents the hash code for the previous versions. 0N/A * Returns whether this <code>Calendar</code> represents a time 0N/A * before the time represented by the specified 0N/A * <code>Object</code>. This method is equivalent to: 0N/A * compareTo(when) < 0 0N/A * </blockquote></pre> 0N/A * if and only if <code>when</code> is a <code>Calendar</code> 0N/A * instance. Otherwise, the method returns <code>false</code>. 0N/A * @param when the <code>Object</code> to be compared 0N/A * @return <code>true</code> if the time of this 0N/A * <code>Calendar</code> is before the time represented by 0N/A * <code>when</code>; <code>false</code> otherwise. 0N/A * @see #compareTo(Calendar) 0N/A * Returns whether this <code>Calendar</code> represents a time 0N/A * after the time represented by the specified 0N/A * <code>Object</code>. This method is equivalent to: 0N/A * compareTo(when) > 0 0N/A * </blockquote></pre> 0N/A * if and only if <code>when</code> is a <code>Calendar</code> 0N/A * instance. Otherwise, the method returns <code>false</code>. 0N/A * @param when the <code>Object</code> to be compared 0N/A * @return <code>true</code> if the time of this <code>Calendar</code> is 0N/A * after the time represented by <code>when</code>; <code>false</code> 0N/A * @see #compareTo(Calendar) 0N/A * Compares the time values (millisecond offsets from the <a 0N/A * href="#Epoch">Epoch</a>) represented by two 0N/A * <code>Calendar</code> objects. 0N/A * @param anotherCalendar the <code>Calendar</code> to be compared. 0N/A * @return the value <code>0</code> if the time represented by the argument 0N/A * is equal to the time represented by this <code>Calendar</code>; a value 0N/A * less than <code>0</code> if the time of this <code>Calendar</code> is 0N/A * before the time represented by the argument; and a value greater than 0N/A * <code>0</code> if the time of this <code>Calendar</code> is after the 0N/A * time represented by the argument. 0N/A * @exception NullPointerException if the specified <code>Calendar</code> is 0N/A * <code>null</code>. 0N/A * @exception IllegalArgumentException if the time value of the 0N/A * specified <code>Calendar</code> object can't be obtained due to 0N/A * any invalid calendar values. 0N/A * Adds or subtracts the specified amount of time to the given calendar field, 0N/A * based on the calendar's rules. For example, to subtract 5 days from 0N/A * the current time of the calendar, you can achieve it by calling: 0N/A * <p><code>add(Calendar.DAY_OF_MONTH, -5)</code>. 0N/A * @param field the calendar field. 0N/A * @param amount the amount of date or time to be added to the field. 0N/A * @see #roll(int,int) 0N/A * @see #set(int,int) 0N/A * Adds or subtracts (up/down) a single unit of time on the given time 0N/A * field without changing larger fields. For example, to roll the current 0N/A * date up by one day, you can achieve it by calling: 0N/A * <p>roll(Calendar.DATE, true). 0N/A * When rolling on the year or Calendar.YEAR field, it will roll the year 0N/A * value in the range between 1 and the value returned by calling 0N/A * <code>getMaximum(Calendar.YEAR)</code>. 0N/A * When rolling on the month or Calendar.MONTH field, other fields like 0N/A * date might conflict and, need to be changed. For instance, 0N/A * rolling the month on the date 01/31/96 will result in 02/29/96. 0N/A * When rolling on the hour-in-day or Calendar.HOUR_OF_DAY field, it will 0N/A * roll the hour value in the range between 0 and 23, which is zero-based. 0N/A * @param field the time field. 0N/A * @param up indicates if the value of the specified time field is to be 0N/A * rolled up or rolled down. Use true if rolling up, false otherwise. 0N/A * @see Calendar#add(int,int) 0N/A * @see Calendar#set(int,int) 0N/A * Adds the specified (signed) amount to the specified calendar field 0N/A * without changing larger fields. A negative amount means to roll 0N/A * <p>NOTE: This default implementation on <code>Calendar</code> just repeatedly calls the 0N/A * version of {@link #roll(int,boolean) roll()} that rolls by one unit. This may not 0N/A * always do the right thing. For example, if the <code>DAY_OF_MONTH</code> field is 31, 0N/A * rolling through February will leave it set to 28. The <code>GregorianCalendar</code> 0N/A * version of this function takes care of this problem. Other subclasses 0N/A * should also provide overrides of this function that do the right thing. 0N/A * @param field the calendar field. 0N/A * @param amount the signed amount to add to the calendar <code>field</code>. 0N/A * @see #roll(int,boolean) 0N/A * @see #add(int,int) 0N/A * @see #set(int,int) 0N/A * Sets the time zone with the given time zone value. 0N/A * @param value the given time zone. 0N/A /* Recompute the fields from the time using the new zone. This also 0N/A * works if isTimeSet is false (after a call to set()). In that case 0N/A * the time will be computed from the fields using the new zone, then 0N/A * the fields will get recomputed from that. Consider the sequence of 0N/A * calls: cal.setTimeZone(EST); cal.set(HOUR, 1); cal.setTimeZone(PST). 0N/A * Is cal set to 1 o'clock EST or 1 o'clock PST? Answer: PST. More 0N/A * generally, a call to setTimeZone() affects calls to set() BEFORE AND 0N/A * AFTER it up to the next call to complete(). 0N/A * Gets the time zone. 0N/A * @return the time zone object associated with this calendar. 0N/A // If the TimeZone object is shared by other Calendar instances, then 0N/A * Returns the time zone (without cloning). 0N/A * Sets the sharedZone flag to <code>shared</code>. 0N/A * Specifies whether or not date/time interpretation is to be lenient. With 0N/A * lenient interpretation, a date such as "February 942, 1996" will be 0N/A * treated as being equivalent to the 941st day after February 1, 1996. 0N/A * With strict (non-lenient) interpretation, such dates will cause an exception to be 0N/A * thrown. The default is lenient. 0N/A * @param lenient <code>true</code> if the lenient mode is to be turned 0N/A * on; <code>false</code> if it is to be turned off. 0N/A * @see java.text.DateFormat#setLenient 0N/A * Tells whether date/time interpretation is to be lenient. 0N/A * @return <code>true</code> if the interpretation mode of this calendar is lenient; 0N/A * <code>false</code> otherwise. 0N/A * @see #setLenient(boolean) 0N/A * Sets what the first day of the week is; e.g., <code>SUNDAY</code> in the U.S., 0N/A * <code>MONDAY</code> in France. 0N/A * @param value the given first day of the week. 0N/A * @see #getFirstDayOfWeek() 0N/A * @see #getMinimalDaysInFirstWeek() 0N/A * Gets what the first day of the week is; e.g., <code>SUNDAY</code> in the U.S., 0N/A * <code>MONDAY</code> in France. 0N/A * @return the first day of the week. 0N/A * @see #setFirstDayOfWeek(int) 0N/A * @see #getMinimalDaysInFirstWeek() 0N/A * Sets what the minimal days required in the first week of the year are; 0N/A * For example, if the first week is defined as one that contains the first 0N/A * day of the first month of a year, call this method with value 1. If it 0N/A * must be a full week, use value 7. 0N/A * @param value the given minimal days required in the first week 0N/A * @see #getMinimalDaysInFirstWeek() 0N/A * Gets what the minimal days required in the first week of the year are; 0N/A * e.g., if the first week is defined as one that contains the first day 0N/A * of the first month of a year, this method returns 1. If 0N/A * the minimal days required must be a full week, this method 0N/A * @return the minimal days required in the first week of the year. 0N/A * @see #setMinimalDaysInFirstWeek(int) 2702N/A * Returns whether this {@code Calendar} supports week dates. 2702N/A * <p>The default implementation of this method returns {@code false}. 2702N/A * @return {@code true} if this {@code Calendar} supports week dates; 2702N/A * @see #setWeekDate(int,int,int) 2702N/A * @see #getWeeksInWeekYear() 2702N/A * Returns the week year represented by this {@code Calendar}. The 2702N/A * week year is in sync with the week cycle. The {@linkplain 2702N/A * #getFirstDayOfWeek() first day of the first week} is the first 2702N/A * <p>The default implementation of this method throws an 2702N/A * {@link UnsupportedOperationException}. 2702N/A * @return the week year of this {@code Calendar} 2702N/A * @exception UnsupportedOperationException 2702N/A * if any week year numbering isn't supported 2702N/A * in this {@code Calendar}. 2702N/A * @see #isWeekDateSupported() 2702N/A * @see #getFirstDayOfWeek() 2702N/A * @see #getMinimalDaysInFirstWeek() 2702N/A * Sets the date of this {@code Calendar} with the the given date 2702N/A * specifiers - week year, week of year, and day of week. 2702N/A * <p>Unlike the {@code set} method, all of the calendar fields 2702N/A * and {@code time} values are calculated upon return. 2702N/A * <p>If {@code weekOfYear} is out of the valid week-of-year range 2702N/A * in {@code weekYear}, the {@code weekYear} and {@code 2702N/A * weekOfYear} values are adjusted in lenient mode, or an {@code 2702N/A * IllegalArgumentException} is thrown in non-lenient mode. 2702N/A * <p>The default implementation of this method throws an 2702N/A * {@code UnsupportedOperationException}. 2702N/A * @param weekYear the week year 2702N/A * @param weekOfYear the week number based on {@code weekYear} 2702N/A * @param dayOfWeek the day of week value: one of the constants 2702N/A * for the {@link #DAY_OF_WEEK} field: {@link 2702N/A * #SUNDAY}, ..., {@link #SATURDAY}. 2702N/A * @exception IllegalArgumentException 2702N/A * if any of the given date specifiers is invalid 2702N/A * or any of the calendar fields are inconsistent 2702N/A * with the given date specifiers in non-lenient mode 2702N/A * @exception UnsupportedOperationException 2702N/A * if any week year numbering isn't supported in this 2702N/A * @see #isWeekDateSupported() 2702N/A * @see #getFirstDayOfWeek() 2702N/A * @see #getMinimalDaysInFirstWeek() 2702N/A * Returns the number of weeks in the week year represented by this 2702N/A * <p>The default implementation of this method throws an 2702N/A * {@code UnsupportedOperationException}. 2702N/A * @return the number of weeks in the week year. 2702N/A * @exception UnsupportedOperationException 2702N/A * if any week year numbering isn't supported in this 2702N/A * @see #isWeekDateSupported() 2702N/A * @see #getActualMaximum(int) 0N/A * Returns the minimum value for the given calendar field of this 0N/A * <code>Calendar</code> instance. The minimum value is defined as 0N/A * the smallest value returned by the {@link #get(int) get} method 0N/A * for any possible time value. The minimum value depends on 0N/A * calendar system specific parameters of the instance. 0N/A * @param field the calendar field. 0N/A * @return the minimum value for the given calendar field. 0N/A * @see #getMaximum(int) 0N/A * @see #getGreatestMinimum(int) 0N/A * @see #getLeastMaximum(int) 0N/A * @see #getActualMinimum(int) 0N/A * @see #getActualMaximum(int) 0N/A * Returns the maximum value for the given calendar field of this 0N/A * <code>Calendar</code> instance. The maximum value is defined as 0N/A * the largest value returned by the {@link #get(int) get} method 0N/A * for any possible time value. The maximum value depends on 0N/A * calendar system specific parameters of the instance. 0N/A * @param field the calendar field. 0N/A * @return the maximum value for the given calendar field. 0N/A * @see #getMinimum(int) 0N/A * @see #getGreatestMinimum(int) 0N/A * @see #getLeastMaximum(int) 0N/A * @see #getActualMinimum(int) 0N/A * @see #getActualMaximum(int) 0N/A * Returns the highest minimum value for the given calendar field 0N/A * of this <code>Calendar</code> instance. The highest minimum 0N/A * value is defined as the largest value returned by {@link 0N/A * #getActualMinimum(int)} for any possible time value. The 0N/A * greatest minimum value depends on calendar system specific 0N/A * parameters of the instance. 0N/A * @param field the calendar field. 0N/A * @return the highest minimum value for the given calendar field. 0N/A * @see #getMinimum(int) 0N/A * @see #getMaximum(int) 0N/A * @see #getLeastMaximum(int) 0N/A * @see #getActualMinimum(int) 0N/A * @see #getActualMaximum(int) 0N/A * Returns the lowest maximum value for the given calendar field 0N/A * of this <code>Calendar</code> instance. The lowest maximum 0N/A * value is defined as the smallest value returned by {@link 0N/A * #getActualMaximum(int)} for any possible time value. The least 0N/A * maximum value depends on calendar system specific parameters of 0N/A * the instance. For example, a <code>Calendar</code> for the 0N/A * Gregorian calendar system returns 28 for the 0N/A * <code>DAY_OF_MONTH</code> field, because the 28th is the last 0N/A * day of the shortest month of this calendar, February in a 0N/A * @param field the calendar field. 0N/A * @return the lowest maximum value for the given calendar field. 0N/A * @see #getMinimum(int) 0N/A * @see #getMaximum(int) 0N/A * @see #getGreatestMinimum(int) 0N/A * @see #getActualMinimum(int) 0N/A * @see #getActualMaximum(int) 0N/A * Returns the minimum value that the specified calendar field 0N/A * could have, given the time value of this <code>Calendar</code>. 0N/A * <p>The default implementation of this method uses an iterative 0N/A * algorithm to determine the actual minimum value for the 0N/A * calendar field. Subclasses should, if possible, override this 0N/A * with a more efficient implementation - in many cases, they can 0N/A * simply return <code>getMinimum()</code>. 0N/A * @param field the calendar field 0N/A * @return the minimum of the given calendar field for the time 0N/A * value of this <code>Calendar</code> 0N/A * @see #getMinimum(int) 0N/A * @see #getMaximum(int) 0N/A * @see #getGreatestMinimum(int) 0N/A * @see #getLeastMaximum(int) 0N/A * @see #getActualMaximum(int) 0N/A // if we know that the minimum value is always the same, just return it 0N/A // clone the calendar so we don't mess with the real one, and set it to 0N/A // accept anything for the field values 0N/A // now try each value from getLeastMaximum() to getMaximum() one by one until 0N/A // we get a value that normalizes to another value. The last value that 0N/A // normalizes to itself is the actual minimum for the current date 0N/A * Returns the maximum value that the specified calendar field 0N/A * could have, given the time value of this 0N/A * <code>Calendar</code>. For example, the actual maximum value of 0N/A * the <code>MONTH</code> field is 12 in some years, and 13 in 0N/A * other years in the Hebrew calendar system. 0N/A * <p>The default implementation of this method uses an iterative 0N/A * algorithm to determine the actual maximum value for the 0N/A * calendar field. Subclasses should, if possible, override this 0N/A * with a more efficient implementation. 0N/A * @param field the calendar field 0N/A * @return the maximum of the given calendar field for the time 0N/A * value of this <code>Calendar</code> 0N/A * @see #getMinimum(int) 0N/A * @see #getMaximum(int) 0N/A * @see #getGreatestMinimum(int) 0N/A * @see #getLeastMaximum(int) 0N/A * @see #getActualMinimum(int) 0N/A // if we know that the maximum value is always the same, just return it. 0N/A // clone the calendar so we don't mess with the real one, and set it to 0N/A // accept anything for the field values. 0N/A // if we're counting weeks, set the day of the week to Sunday. We know the 0N/A // last week of a month or year will contain the first day of the week. 0N/A // now try each value from getLeastMaximum() to getMaximum() one by one until 0N/A // we get a value that normalizes to another value. The last value that 0N/A // normalizes to itself is the actual maximum for the current date 0N/A * Creates and returns a copy of this object. 0N/A * @return a copy of this object. 0N/A // this shouldn't happen, since we are Cloneable 0N/A "ERA",
"YEAR",
"MONTH",
"WEEK_OF_YEAR",
"WEEK_OF_MONTH",
"DAY_OF_MONTH",
0N/A "DAY_OF_YEAR",
"DAY_OF_WEEK",
"DAY_OF_WEEK_IN_MONTH",
"AM_PM",
"HOUR",
0N/A "HOUR_OF_DAY",
"MINUTE",
"SECOND",
"MILLISECOND",
"ZONE_OFFSET",
0N/A * Returns the name of the specified calendar field. 0N/A * @param field the calendar field 0N/A * @return the calendar field name 0N/A * @exception IndexOutOfBoundsException if <code>field</code> is negative, 0N/A * equal to or greater then <code>FIELD_COUNT</code>. 0N/A * Return a string representation of this calendar. This method 0N/A * is intended to be used only for debugging purposes, and the 0N/A * format of the returned string may vary between implementations. 0N/A * The returned string may be empty but may not be <code>null</code>. 0N/A * @return a string representation of this calendar. 0N/A // NOTE: BuddhistCalendar.toString() interprets the string 0N/A // produced by this method so that the Gregorian year number 0N/A // is substituted by its B.E. year value. It relies on 0N/A // "...,YEAR=<year>,..." or "...,YEAR=?,...". 0N/A // =======================privates=============================== 0N/A * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. 0N/A * They are used to figure out the week count for a specific date for 0N/A * a given locale. These must be set when a Calendar is constructed. 0N/A * @param desiredLocale the given locale. 0N/A /* try to get the Locale data from the cache */ 0N/A * Recomputes the time and updates the status fields isTimeSet 0N/A * and areFieldsSet. Callers should check isTimeSet and only 0N/A * call this method if isTimeSet is false. 0N/A // The areFieldsSet and areAllFieldsSet values are no longer 0N/A // controlled here (as of 1.5). 0N/A * Adjusts the stamp[] values before nextStamp overflow. nextStamp 0N/A * is set to the next stamp value upon the return. 0N/A * Sets the WEEK_OF_MONTH and WEEK_OF_YEAR fields to new values with the 0N/A * new parameter value if they have been calculated internally. 0N/A // We have to check the new values of these fields after changing 0N/A // firstDayOfWeek and/or minimalDaysInFirstWeek. If the field values 0N/A // have been changed, then set the new values. (4822110) 0N/A * Save the state of this object to a stream (i.e., serialize it). 0N/A * Ideally, <code>Calendar</code> would only write out its state data and 0N/A * the current time, and not write any field data out, such as 0N/A * <code>fields[]</code>, <code>isTimeSet</code>, <code>areFieldsSet</code>, 0N/A * and <code>isSet[]</code>. <code>nextStamp</code> also should not be part 0N/A * of the persistent state. Unfortunately, this didn't happen before JDK 1.1 0N/A * shipped. To be compatible with JDK 1.1, we will always have to write out 0N/A * the field values and state flags. However, <code>nextStamp</code> can be 0N/A * removed from the serialization stream; this will probably happen in the 0N/A // Try to compute the time correctly, for the future (stream 0N/A // version 2) in which we don't write out fields[] or isSet[]. 0N/A // If this Calendar has a ZoneInfo, save it and set a 0N/A // SimpleTimeZone equivalent (as a single DST schedule) for 0N/A // backward compatibility. 0N/A // Write out the 1.1 FCS object. 0N/A // Write out the ZoneInfo object 0N/A // 4802409: we write out even if it is null, a temporary workaround 0N/A // the real fix for bug 4844924 in corba-iiop 0N/A * Reconstitutes this object from a stream (i.e., deserialize it). 0N/A // Starting with version 2 (not implemented yet), we expect that 0N/A // fields[], isSet[], isTimeSet, and areFieldsSet may not be 0N/A // streamed out anymore. We expect 'time' to be correct. 0N/A // If there's a ZoneInfo object, use it for zone. 0N/A // If the deserialized object has a SimpleTimeZone, try to 0N/A // replace it with a ZoneInfo equivalent (as of 1.4) in order 0N/A // to be compatible with the SimpleTimeZone-based 0N/A // implementation as much as possible.