JapaneseImperialCalendar.java revision 0
0N/A * Copyright 2005-2006 Sun Microsystems, Inc. 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 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun 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. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * <code>JapaneseImperialCalendar</code> implements a Japanese 0N/A * calendar system in which the imperial era-based year numbering is 0N/A * supported from the Meiji era. The following are the eras supported 0N/A * by this calendar system. 0N/A * ERA value Era name Since (in Gregorian) 0N/A * ------------------------------------------------------ 0N/A * 1 Meiji 1868-01-01 midnight local time 0N/A * 2 Taisho 1912-07-30 midnight local time 0N/A * 3 Showa 1926-12-25 midnight local time 0N/A * 4 Heisei 1989-01-08 midnight local time 0N/A * ------------------------------------------------------ 0N/A * <p><code>ERA</code> value 0 specifies the years before Meiji and 0N/A * the Gregorian year values are used. Unlike {@link 0N/A * GregorianCalendar}, the Julian to Gregorian transition is not 0N/A * supported because it doesn't make any sense to the Japanese 0N/A * calendar systems used before Meiji. To represent the years before 0N/A * Gregorian year 1, 0 and negative values are used. The Japanese 0N/A * Imperial rescripts and government decrees don't specify how to deal 0N/A * with time differences for applying the era transitions. This 0N/A * calendar implementation assumes local time for all transitions. 0N/A * @author Masayoshi Okutsu 0N/A * Implementation Notes 0N/A * This implementation uses 0N/A * sun.util.calendar.LocalGregorianCalendar to perform most of the 0N/A * calendar calculations. LocalGregorianCalendar is configurable 0N/A * The ERA constant designating the era before Meiji. 0N/A * The ERA constant designating the Meiji era. 0N/A * The ERA constant designating the Taisho era. 0N/A * The ERA constant designating the Showa era. 0N/A * The ERA constant designating the Heisei era. 0N/A private static final int EPOCH_OFFSET =
719163;
// Fixed date of January 1, 1970 (Gregorian) 0N/A // Useful millisecond constants. Although ONE_DAY and ONE_WEEK can fit 0N/A // into ints, they must be longs in order to prevent arithmetic overflow 0N/A // when performing (bug 4173516). 0N/A // Reference to the sun.util.calendar.LocalGregorianCalendar instance (singleton). 0N/A // Gregorian calendar instance. This is required because era 0N/A // transition dates are given in Gregorian dates. 0N/A // The Era instance representing "before Meiji". 0N/A // Imperial eras. The sun.util.calendar.LocalGregorianCalendar 0N/A // doesn't have an Era representing before Meiji, which is 0N/A // inconvenient for a Calendar. So, era[0] is a reference to 0N/A // BEFORE_MEIJI_ERA. 0N/A // Fixed date of the first date of each era. 0N/A * Field name Minimum Minimum Maximum Maximum 0N/A * ---------- ------- ------- ------- ------- 0N/A * YEAR -292275055 1 ? ? 0N/A * WEEK_OF_YEAR 1 1 52* 53 0N/A * WEEK_OF_MONTH 0 0 4* 6 0N/A * DAY_OF_MONTH 1 1 28* 31 0N/A * DAY_OF_YEAR 1 1 365* 366 0N/A * DAY_OF_WEEK 1 1 7 7 0N/A * DAY_OF_WEEK_IN_MONTH -1 -1 4* 6 0N/A * HOUR_OF_DAY 0 0 23 23 0N/A * MILLISECOND 0 0 999 999 0N/A * ZONE_OFFSET -13:00 -13:00 14:00 14:00 0N/A * DST_OFFSET 0:00 0:00 0:20 2:00 0N/A * *: depends on eras 0N/A 1,
// DAY_OF_WEEK_IN_MONTH 0N/A 0,
// ERA (initialized later) 0N/A 0,
// YEAR (initialized later) 0N/A 0,
// WEEK_OF_YEAR (Showa 1 has only 6 days which could be 0 weeks.) 0N/A 0,
// DAY_OF_YEAR (initialized later) 0N/A 4,
// DAY_OF_WEEK_IN 0N/A 6,
// DAY_OF_WEEK_IN 0N/A // Proclaim serialization compatibility with JDK 1.6 0N/A // eras[BEFORE_MEIJI] and sinceFixedDate[BEFORE_MEIJI] are the 0N/A // same as Gregorian. 0N/A // Calculate the least maximum year and least day of Year 0N/A // values. The following code assumes that there's at most one 0N/A // era transition in a Gregorian year. 0N/A // Unless the first year starts from January 1, the actual 0N/A // max value could be one year short. For example, if it's 0N/A // Showa 63 January 8, 63 is the actual max value since 0N/A // Showa 64 January 8 doesn't exist. 0N/A * jdate always has a sun.util.calendar.LocalGregorianCalendar.Date instance to 0N/A * avoid overhead of creating it for each calculation. 0N/A * Temporary int[2] to get time zone offsets. zoneOffsets[0] gets 0N/A * the GMT offset value and zoneOffsets[1] gets the daylight saving 0N/A * Temporary storage for saving original fields[] values in 0N/A * Constructs a <code>JapaneseImperialCalendar</code> based on the current time 0N/A * in the given time zone with the given locale. 0N/A * @param zone the given time zone. 0N/A * @param aLocale the given locale. 0N/A * Compares this <code>JapaneseImperialCalendar</code> to the specified 0N/A * <code>Object</code>. The result is <code>true</code> if and 0N/A * only if the argument is a <code>JapaneseImperialCalendar</code> object 0N/A * that represents the same time value (millisecond offset from 0N/A * <code>Calendar</code> parameters. 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 * @see Calendar#compareTo(Calendar) 0N/A * Generates the hash code for this 0N/A * <code>JapaneseImperialCalendar</code> object. 0N/A * Adds the specified (signed) amount of time to the given calendar field, 0N/A * based on the calendar's rules. 0N/A * <p><em>Add rule 1</em>. The value of <code>field</code> 0N/A * after the call minus the value of <code>field</code> before the 0N/A * call is <code>amount</code>, modulo any overflow that has occurred in 0N/A * <code>field</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><em>Add rule 2</em>. 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 0N/A * <code>field</code> is changed, 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 * @param field the calendar field. 0N/A * @param amount the amount of date or time to be added to the field. 0N/A * @exception IllegalArgumentException if <code>field</code> is 0N/A * <code>ZONE_OFFSET</code>, <code>DST_OFFSET</code>, or unknown, 0N/A * or if any calendar fields have out-of-range values in 0N/A // If amount == 0, do nothing even the given field is out of 0N/A // range. This is tested by JCK. 0N/A return;
// Do nothing! 0N/A // Sync the time and calendar fields. 0N/A // Handle the time fields here. Convert the given 0N/A // amount to milliseconds and call setTimeInMillis. 0N/A delta *=
60 *
60 *
1000;
// hours to milliseconds 0N/A delta *=
60 *
1000;
// minutes to milliseconds 0N/A delta *=
1000;
// seconds to milliseconds 0N/A // Handle week, day and AM_PM fields which involves 0N/A // time zone offset change adjustment. Convert the 0N/A // given amount to the number of days. 0N/A // Convert the amount to the number of days (delta) 0N/A // and +12 or -12 hours (timeOfDay). 0N/A // The time fields don't require time zone offset change 0N/A // The rest of the fields (week, day or AM_PM fields) 0N/A // require time zone offset (both GMT and DST) change 0N/A // Translate the current time to the fixed date and time 0N/A fd +=
delta;
// fd is the expected fixed date after the calculation 0N/A // If the time zone offset has changed, then adjust the difference. 0N/A // If the adjustment has changed the date, then take 0N/A // the previous one. 0N/A * Adds a signed amount to the specified calendar field without changing larger fields. 0N/A * A negative roll amount means to subtract from field without changing 0N/A * larger fields. If the specified amount is 0, this method performs nothing. 0N/A * <p>This method calls {@link #complete()} before adding the 0N/A * amount so that all the calendar fields are normalized. If there 0N/A * is any calendar field having an out-of-range value in non-lenient mode, then an 0N/A * <code>IllegalArgumentException</code> is thrown. 0N/A * @param field the calendar field. 0N/A * @param amount the signed amount to add to <code>field</code>. 0N/A * @exception IllegalArgumentException if <code>field</code> is 0N/A * <code>ZONE_OFFSET</code>, <code>DST_OFFSET</code>, or unknown, 0N/A * or if any calendar fields have out-of-range values in 0N/A * @see #roll(int,boolean) 0N/A * @see #add(int,int) 0N/A * @see #set(int,int) 0N/A // If amount == 0, do nothing even the given field is out of 0N/A // range. This is tested by JCK. 0N/A // Sync the time and calendar fields. 0N/A // These fields are handled simply, since they have fixed 0N/A // minima and maxima. Other fields are complicated, since 0N/A // the range within they must roll varies depending on the 0N/A // date, a time zone and the era transitions. 0N/A // The day might have changed, which could happen if 0N/A // the daylight saving time transition brings it to 0N/A // the next day, although it's very unlikely. But we 0N/A // have to make sure not to change the larger fields. 0N/A // Time zone offset and/or daylight saving might have changed. 0N/A // Rolling the month involves both pinning the final value to [0, 11] 0N/A // and adjusting the DAY_OF_MONTH if necessary. We only adjust the 0N/A // DAY_OF_MONTH if, after updating the MONTH field, it is illegal. 0N/A // E.g., <jan31>.roll(MONTH, 1) -> <feb28> or <feb29>. 0N/A // To avoid overflow, use an equivalent year. 0N/A // Month may have changed by the normalization. 0N/A // To avoid underflow, use an equivalent year. 0N/A // Month may have changed by the normalization. 0N/A // Keep the day of month in the range. We 0N/A // don't want to spill over into the next 0N/A // month; e.g., we don't want jan31 + 1 mo -> 0N/A // The year has only one month. No need to 0N/A // process further. (Showa Gan-nen (year 1) 0N/A // and the last year have only one month.) 0N/A // If the new value is in between min and max 0N/A // (exclusive), then we can use the value. 0N/A // Make sure that the min week has the current DAY_OF_WEEK 0N/A // Make sure the same thing for the max week 0N/A // Handle transition here. 0N/A // Make sure that the min week has the current DAY_OF_WEEK 0N/A // Make sure the same thing for the max week 0N/A // value: the new WEEK_OF_YEAR which must be converted 0N/A // to month and day of month. 0N/A // dow: relative day of week from the first day of week 0N/A long month1;
// fixed date of the first day (usually 1) of the month 0N/A // the first day of week of the month. 0N/A // if the week has enough days to form a week, the 0N/A // week starts from the previous month. 0N/A // value: the new WEEK_OF_MONTH value 0N/A // nfd: fixed date of the rolled date 0N/A // Unlike WEEK_OF_YEAR, we need to change day of week if the 0N/A // nfd is out of the month. 0N/A // TODO: Need to change the spec to be usable DAY_OF_MONTH rolling... 0N/A // Transition handling. We can't change year and era 0N/A // values here due to the Calendar roll spec! 0N/A // It may not be a regular month. Convert the date and range to 0N/A // the relative values, perform the roll, and 0N/A // convert the result back to the rolled date. 0N/A // Handle transition. We can't change year and era values 0N/A // here due to the Calendar roll spec. 0N/A // If the week of year is in the same year, we can 0N/A // just change DAY_OF_WEEK. 0N/A // We need to handle it in a different way around year 0N/A // boundaries and in the transition year. Note that 0N/A // changing era and year values violates the roll 0N/A // rule: not changing larger calendar fields... 0N/A min =
1;
// after having normalized, min should be 1. 0N/A // Transition year handling. 0N/A // "GanNen" is supported only in the LONG style. 0N/A // If the ERA value is out of range for strings, then 0N/A // try to get its name or abbreviation from the Era instance. 0N/A // If strings[] has fewer than eras[], get more names from eras[]. 0N/A * Returns the minimum value for the given calendar field of this 0N/A * <code>Calendar</code> instance. The minimum value is 0N/A * defined as the smallest value returned by the {@link 0N/A * Calendar#get(int) get} method for any possible time value, 0N/A * taking into consideration the current values of the 0N/A * {@link Calendar#getFirstDayOfWeek() getFirstDayOfWeek}, 0N/A * {@link Calendar#getMinimalDaysInFirstWeek() getMinimalDaysInFirstWeek}, 0N/A * and {@link Calendar#getTimeZone() getTimeZone} methods. 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>GregorianCalendar</code> instance. The maximum value is 0N/A * defined as the largest value returned by the {@link 0N/A * Calendar#get(int) get} method for any possible time value, 0N/A * taking into consideration the current values of the 0N/A * {@link Calendar#getFirstDayOfWeek() getFirstDayOfWeek}, 0N/A * {@link Calendar#getMinimalDaysInFirstWeek() getMinimalDaysInFirstWeek}, 0N/A * and {@link Calendar#getTimeZone() getTimeZone} methods. 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 // The value should depend on the time zone of this calendar. 0N/A * Returns the highest minimum value for the given calendar field 0N/A * of this <code>GregorianCalendar</code> instance. The highest 0N/A * minimum value is defined as the largest value returned by 0N/A * {@link #getActualMinimum(int)} for any possible time value, 0N/A * taking into consideration the current values of the 0N/A * {@link Calendar#getFirstDayOfWeek() getFirstDayOfWeek}, 0N/A * {@link Calendar#getMinimalDaysInFirstWeek() getMinimalDaysInFirstWeek}, 0N/A * and {@link Calendar#getTimeZone() getTimeZone} methods. 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>GregorianCalendar</code> instance. The lowest 0N/A * maximum value is defined as the smallest value returned by 0N/A * {@link #getActualMaximum(int)} for any possible time value, 0N/A * taking into consideration the current values of the 0N/A * {@link Calendar#getFirstDayOfWeek() getFirstDayOfWeek}, 0N/A * {@link Calendar#getMinimalDaysInFirstWeek() getMinimalDaysInFirstWeek}, 0N/A * and {@link Calendar#getTimeZone() getTimeZone} methods. 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 this calendar field could have, 0N/A * taking into consideration the given time value and the current 0N/A * {@link Calendar#getFirstDayOfWeek() getFirstDayOfWeek}, 0N/A * {@link Calendar#getMinimalDaysInFirstWeek() getMinimalDaysInFirstWeek}, 0N/A * and {@link Calendar#getTimeZone() getTimeZone} methods. 0N/A * @param field the calendar field 0N/A * @return the minimum of the given field for the time value of 0N/A * this <code>JapaneseImperialCalendar</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 // Get a local date which includes time of day and time zone, 0N/A // which are missing in jc.jdate. 0N/A // Use the same year in jd to take care of leap 0N/A // years. i.e., both jd and d must agree on leap 0N/A // Use an equvalent year of d.getYear() if 0N/A // possible. Otherwise, ignore the leap year and 0N/A // common year difference. 0N/A // In Before Meiji and Meiji, January is the first month. 0N/A // shift 400 years to avoid underflow 0N/A * Returns the maximum value that this calendar field could have, 0N/A * taking into consideration the given time value and the current 0N/A * {@link Calendar#getFirstDayOfWeek() getFirstDayOfWeek}, 0N/A * {@link Calendar#getMinimalDaysInFirstWeek() getMinimalDaysInFirstWeek}, 0N/A * {@link Calendar#getTimeZone() getTimeZone} methods. 0N/A * For example, if the date of this instance is Heisei 16February 1, 0N/A * the actual maximum value of the <code>DAY_OF_MONTH</code> field 0N/A * is 29 because Heisei 16 is a leap year, and if the date of this 0N/A * instance is Heisei 17 February 1, it's 28. 0N/A * @param field the calendar field 0N/A * @return the maximum of the given field for the time value of 0N/A * this <code>JapaneseImperialCalendar</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 // TODO: there may be multiple transitions in a year. 0N/A // Handle transition year. 0N/A // TODO: there may be multiple transitions in a year. 0N/A // shift 400 years to avoid underflow 0N/A // Get the day of week of January 1 of the year 0N/A // Normalize the day of week with the firstDayOfWeek value 0N/A // Use an equivalent year for the 0N/A // getYearOffsetInMillis call to avoid overflow. 0N/A // Use the same year as d.getYear() to be 0N/A // consistent with leap and common years. 0N/A * Returns the millisecond offset from the beginning of the 0N/A * year. In the year for Long.MIN_VALUE, it's a pseudo value 0N/A * beyond the limit. The given CalendarDate object must have been 0N/A * normalized before calling this method. 0N/A // To share the zone by the CalendarDate 0N/A // To share the zone by the CalendarDate 0N/A * The fixed date corresponding to jdate. If the value is 0N/A * Long.MIN_VALUE, the fixed date value is unknown. 0N/A * Converts the time value (millisecond offset from the <a 0N/A * The time is <em>not</em> 0N/A * recomputed first; to recompute the time, then the fields, call the 0N/A * <code>complete</code> method. 0N/A * @see Calendar#complete 0N/A // Determine which calendar fields need to be computed. 0N/A // Specify all fields 0N/A // After computing all the fields, set the field state to `COMPUTED'. 0N/A * This computeFields implements the conversion from UTC 0N/A * (millisecond offset from the Epoch) to calendar 0N/A * field values. fieldMask specifies which fields to change the 0N/A * setting state to COMPUTED, although all fields are set to 0N/A * the correct values. This is required to fix 4685354. 0N/A * @param fieldMask a bit mask to specify which fields to change 0N/A * the setting state. 0N/A * @param tzMask a bit mask to specify which time zone offset 0N/A * fields to be used for time calculations 0N/A * @return a new field mask that indicates what field values have 0N/A * actually been set. 0N/A // By computing time and zoneOffset separately, we can take 0N/A // the wider range of time+zoneOffset than the previous 0N/A // See if we can use jdate to avoid date calculation. 0N/A // Always set the ERA and YEAR values. 0N/A // Set the basic date fields. 0N/A // If it's a year of an era transition, we need to handle 0N/A // irregular year boundaries. 0N/A // The spec is to calculate WEEK_OF_YEAR in the 0N/A // ISO8601-style. This creates problems, though. 0N/A // If the date belongs to the last week of the 0N/A // previous year, use the week number of "12/31" of 0N/A // the "previous" year. Again, if the previous year is 0N/A // a transition year, we need to take care of it. 0N/A // Usually the previous day of the first day of a year 0N/A // is December 31, which is not always true in the 0N/A // Japanese imperial calendar system. 0N/A // As of Heisei (since Meiji) there's no case 0N/A // that there are multiple transitions in a 0N/A // year. Historically there was such 0N/A // case. There might be such case again in the 0N/A // The first days forms a week in which the date is included. 0N/A // The first days forms a week in which the date is included. 0N/A * Returns the number of weeks in a period between fixedDay1 and 0N/A * fixedDate. The getFirstDayOfWeek-getMinimalDaysInFirstWeek rule 0N/A * is applied to calculate the number of weeks. 0N/A * @param fixedDay1 the fixed date of the first day of the period 0N/A * @param fixedDate the fixed date of the last day of the period 0N/A * @return the number of weeks of the given period 0N/A // We can always use `jcal' since Julian and Gregorian are the 0N/A // same thing for this calculation. 0N/A * Converts calendar field values to the time value (millisecond 0N/A * @exception IllegalArgumentException if any calendar fields are invalid. 0N/A // In non-lenient mode, perform brief checking of calendar 0N/A // fields which have been set externally. Through this 0N/A // checking, the field values are stored in originalFields[] 0N/A // to see if any of them are normalized later. 0N/A // Quick validation for any out of range values 0N/A // Let the super class determine which calendar fields to be 0N/A // used to calculate the time. 0N/A // Equivalent to 1970 (Gregorian) 0N/A // Calculate the time of day. We rely on the convention that 0N/A // an UNSET field has 0. 0N/A // The default value of AM_PM is 0 which designates AM. 0N/A // Convert the time of day to the number of days and the 0N/A // millisecond offset from midnight. 0N/A // Calculate the fixed date since January 1, 1 (Gregorian). 0N/A // millis represents local wall-clock time in milliseconds. 0N/A // Compute the time zone offset and DST offset. There are two potential 0N/A // ambiguities here. We'll assume a 2:00 am (wall time) switchover time 0N/A // for discussion purposes here. 0N/A // 1. The transition into DST. Here, a designated time of 2:00 am - 2:59 am 0N/A // can be in standard or in DST depending. However, 2:00 am is an invalid 0N/A // representation (the representation jumps from 1:59:59 am Std to 3:00:00 am DST). 0N/A // We assume standard time. 0N/A // 2. The transition out of DST. Here, a designated time of 1:00 am - 1:59 am 0N/A // can be in standard or DST. Both are valid representations (the rep 0N/A // jumps from 1:59:59 DST to 1:00:00 Std). 0N/A // Again, we assume standard time. 0N/A // We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET 0N/A // or DST_OFFSET fields; then we use those fields. 0N/A // Adjust the time zone offset values to get the UTC time. 0N/A // Set this calendar's time in milliseconds 0N/A // Restore the original field values 0N/A * Computes the fixed date under either the Gregorian or the 0N/A * Julian calendar, using the given year and the specified calendar fields. 0N/A * @param cal the CalendarSystem to be used for the date calculation 0N/A * @param year the normalized year number, with 0 indicating the 0N/A * year 1 BCE, -1 indicating 2 BCE, etc. 0N/A * @param fieldMask the calendar fields to be used for the date calculation 0N/A * @return the fixed date 0N/A * @see Calendar#selectFields 0N/A // No need to check if MONTH has been set (no isSet(MONTH) 0N/A // call) since its unset value happens to be JANUARY (0). 0N/A // If the month is out of range, adjust it into range. 0N/A // Adjust the base date if year is the minimum value. 0N/A // Get the fixed date since Jan 1, 1 (Gregorian). We are on 0N/A // the first day of either `month' or January in 'year'. 0N/A // Month-based calculations 0N/A // We are on the "first day" of the month (which may 0N/A // not be 1). Just add the offset if DAY_OF_MONTH is 0N/A // set. If the isSet call returns false, that means 0N/A // DAY_OF_MONTH has been selected just because of the 0N/A // selected combination. We don't need to add any 0N/A // since the default value is the "first day". 0N/A // To avoid underflow with DAY_OF_MONTH-firstDayOfMonth, add 0N/A // DAY_OF_MONTH, then subtract firstDayOfMonth. 0N/A // If we have enough days in the first week, then 0N/A // move to the previous week. 0N/A // In lenient mode, we treat days of the previous 0N/A // months as a part of the specified 0N/A // WEEK_OF_MONTH. See 4633646. 0N/A // We are basing this on the day-of-week-in-month. The only 0N/A // trickiness occurs if the day-of-week-in-month is 0N/A // Go to the first day of the next week of 0N/A // the specified week boundary. 0N/A // Then, get the day of week date on or before the last date. 0N/A // We are on the first day of the year. 0N/A // Add the offset, then subtract 1. (Make sure to avoid underflow.) 0N/A // If we have enough days in the first week, then move 0N/A // to the previous week. 0N/A * Returns the fixed date of the first day of the year (usually 0N/A * January 1) before the specified date. 0N/A * @param date the date for which the first day of the year is 0N/A * calculated. The date has to be in the cut-over year. 0N/A * @param fixedDate the fixed date representation of the date 0N/A // There might be multiple era transitions in a year. 0N/A * Returns the fixed date of the first date of the month (usually 0N/A * the 1st of the month) before the specified date. 0N/A * @param date the date for which the first day of the month is 0N/A * calculated. The date must be in the era transition year. 0N/A * @param fixedDate the fixed date representation of the date 0N/A // If the given date is on or after the transition date, then 0N/A // return the transition date. 0N/A // Otherwise, we can use the 1st day of the month. 0N/A * Returns a LocalGregorianCalendar.Date produced from the specified fixed date. 0N/A * @param fd the fixed date 0N/A * Returns the length of the specified month in the specified 0N/A * Gregorian year. The year number must be normalized. 0N/A * @see #isLeapYear(int) 0N/A * Returns the length of the specified month in the year provided 0N/A * by internalGet(YEAR). 0N/A * @see #isLeapYear(int) 0N/A * Returns the index to the new era if the given date is in a 0N/A * transition month. For example, if the give date is Heisei 1 0N/A * (1989) January 20, then the era index for Heisei is 0N/A * returned. Likewise, if the given date is Showa 64 (1989) 0N/A * January 3, then the era index for Heisei is returned. If the 0N/A * given date is not in any transition month, then -1 is returned. 0N/A * Returns this object if it's normalized (all fields and time are 0N/A * in sync). Otherwise, a cloned object is returned after calling 0N/A * complete() in lenient mode. 0N/A // Create a clone and normalize the calendar fields 0N/A * After adjustments such as add(MONTH), add(YEAR), we don't want the 0N/A * month to jump around. E.g., we don't want Jan 31 + 1 month to go to Mar 0N/A * 3, we want it to go to Feb 28. Adjustments which might run into this 0N/A * problem call this method to retain the proper month. 0N/A // Use an equivalent year. 0N/A // restore the year. 0N/A // Don't normalize date here so as not to cause underflow. 0N/A * Returns the new value after 'roll'ing the specified value and amount. 0N/A * Returns the ERA. We need a special method for this because the 0N/A * default ERA is the current era, but a zero (unset) ERA means before Meiji. 0N/A * Updates internal state.