2362N/A * Copyright (c) 2000, 2005, 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 * <code>CalendarSystem</code> is an abstract class that defines the 0N/A * programming interface to deal with calendar date and time. 0N/A * <p><code>CalendarSystem</code> instances are singletons. For 0N/A * example, there exists only one Gregorian calendar instance in the 0N/A * Java runtime environment. A singleton instance can be obtained 0N/A * calling one of the static factory methods. 0N/A * <h4>CalendarDate</h4> 0N/A * <p>For the methods in a <code>CalendarSystem</code> that manipulate 0N/A * a <code>CalendarDate</code>, <code>CalendarDate</code>s that have 0N/A * been created by the <code>CalendarSystem</code> must be 0N/A * specified. Otherwise, the methods throw an exception. This is 0N/A * because, for example, a Chinese calendar date can't be understood 0N/A * by the Hebrew calendar system. 0N/A * <h4>Calendar names</h4> 0N/A * Each calendar system has a unique name to be identified. The Java 0N/A * runtime in this release supports the following calendar systems. 0N/A * Name Calendar System 0N/A * --------------------------------------- 0N/A * gregorian Gregorian Calendar 0N/A * julian Julian Calendar 0N/A * japanese Japanese Imperial Calendar 0N/A * @author Masayoshi Okutsu 0N/A /////////////////////// Calendar Factory Methods ///////////////////////// 0N/A // Map of calendar names and calendar class names 0N/A // Map of calendar names and CalendarSystem instances 0N/A "gregorian",
"Gregorian",
0N/A "japanese",
"LocalGregorianCalendar",
0N/A "julian",
"JulianCalendar",
0N/A "hebrew", "HebrewCalendar", 0N/A "iso8601", "ISOCalendar", 0N/A "taiwanese", "LocalGregorianCalendar", 0N/A "thaibuddhist", "LocalGregorianCalendar", 0N/A // Associate a calendar name with its class name and the 0N/A // calendar class name with its date class name. 0N/A * Returns the singleton instance of the <code>Gregorian</code> 0N/A * @return the <code>Gregorian</code> instance 0N/A * Returns a <code>CalendarSystem</code> specified by the calendar 0N/A * name. The calendar name has to be one of the supported calendar 0N/A * @param calendarName the calendar name 0N/A * @return the <code>CalendarSystem</code> specified by 0N/A * <code>calendarName</code>, or null if there is no 0N/A * <code>CalendarSystem</code> associated with the given calendar name. 0N/A return null;
// Unknown calendar name 0N/A // Create the specific kind of local Gregorian calendar system 0N/A //////////////////////////////// Calendar API ////////////////////////////////// 0N/A * Returns the name of this calendar system. 0N/A * Calculates calendar fields from the specified number of 0N/A * milliseconds since the Epoch, January 1, 1970 00:00:00 UTC 0N/A * (Gregorian). This method doesn't check overflow or underflow 0N/A * when adjusting the millisecond value (representing UTC) with 0N/A * the time zone offsets (i.e., the GMT offset and amount of 0N/A * @param millis the offset value in milliseconds from January 1, 0N/A * 1970 00:00:00 UTC (Gregorian). 0N/A * @return a <code>CalendarDate</code> instance that contains the 0N/A * calculated calendar field values. 0N/A * Constructs a <code>CalendarDate</code> that is specific to this 0N/A * calendar system. All calendar fields have their initial 0N/A * values. The {@link TimeZone#getDefault() default time zone} is 0N/A * set to the instance. 0N/A * @return a <code>CalendarDate</code> instance that contains the initial 0N/A * calendar field values. 0N/A * Returns the number of milliseconds since the Epoch, January 1, 0N/A * 1970 00:00:00 UTC (Gregorian), represented by the specified 0N/A * <code>CalendarDate</code>. 0N/A * @param date the <code>CalendarDate</code> from which the time 0N/A * value is calculated 0N/A * @return the number of milliseconds since the Epoch. 0N/A * Returns the length in days of the specified year by 0N/A * <code>date</code>. This method does not perform the 0N/A * normalization with the specified <code>CalendarDate</code>. The 0N/A * <code>CalendarDate</code> must be normalized to get a correct 0N/A * Returns the number of months of the specified year. This method 0N/A * does not perform the normalization with the specified 0N/A * <code>CalendarDate</code>. The <code>CalendarDate</code> must 0N/A * be normalized to get a correct value. 0N/A * Returns the length in days of the month specified by the calendar 0N/A * date. This method does not perform the normalization with the 0N/A * specified calendar date. The <code>CalendarDate</code> must 0N/A * be normalized to get a correct value. 0N/A * @param date the date from which the month value is obtained 0N/A * @return the number of days in the month 0N/A * @exception IllegalArgumentException if the specified calendar date 0N/A * doesn't have a valid month value in this calendar system. 0N/A * Returns the length in days of a week in this calendar 0N/A * system. If this calendar system has multiple radix weeks, this 0N/A * method returns only one of them. 0N/A * Returns the <code>Era</code> designated by the era name that 0N/A * has to be known to this calendar system. If no Era is 0N/A * applicable to this calendar system, null is returned. 0N/A * @param eraName the name of the era 0N/A * @return the <code>Era</code> designated by 0N/A * <code>eraName</code>, or <code>null</code> if no Era is 0N/A * applicable to this calendar system or the specified era name is 0N/A * not known to this calendar system. 0N/A * Returns valid <code>Era</code>s of this calendar system. The 0N/A * return value is sorted in the descendant order. (i.e., the first 0N/A * element of the returned array is the oldest era.) If no era is 0N/A * applicable to this calendar system, <code>null</code> is returned. 0N/A * @return an array of valid <code>Era</code>s, or 0N/A * <code>null</code> if no era is applicable to this calendar 0N/A * @throws IllegalArgumentException if the specified era name is 0N/A * unknown to this calendar system. 0N/A * Returns a <code>CalendarDate</code> of the n-th day of week 0N/A * which is on, after or before the specified date. For example, the 0N/A * first Sunday in April 2002 (Gregorian) can be obtained as 0N/A * Gregorian cal = CalendarSystem.getGregorianCalendar(); 0N/A * CalendarDate date = cal.newCalendarDate(); 0N/A * date.setDate(2004, cal.APRIL, 1); 0N/A * CalendarDate firstSun = cal.getNthDayOfWeek(1, cal.SUNDAY, date); 0N/A * // firstSun represents April 4, 2004. 0N/A * This method returns a new <code>CalendarDate</code> instance 0N/A * and doesn't modify the original date. 0N/A * @param nth specifies the n-th one. A positive number specifies 0N/A * <em>on or after</em> the <code>date</code>. A non-positive number 0N/A * specifies <em>on or before</em> the <code>date</code>. 0N/A * @param dayOfWeek the day of week 0N/A * @param date the date 0N/A * @return the date of the nth <code>dayOfWeek</code> after 0N/A * or before the specified <code>CalendarDate</code> 0N/A * Checks whether the calendar fields specified by <code>date</code> 0N/A * represents a valid date and time in this calendar system. If the 0N/A * given date is valid, <code>date</code> is marked as <em>normalized</em>. 0N/A * @param date the <code>CalendarDate</code> to be validated 0N/A * @return <code>true</code> if all the calendar fields are consistent, 0N/A * otherwise, <code>false</code> is returned. 0N/A * @exception NullPointerException if the specified 0N/A * <code>date</code> is <code>null</code> 0N/A * Normalizes calendar fields in the specified 0N/A * <code>date</code>. Also all {@link CalendarDate#FIELD_UNDEFINED 0N/A * undefined} fields are set to correct values. The actual 0N/A * normalization process is calendar system dependent. 0N/A * @param date the calendar date to be validated 0N/A * @return <code>true</code> if all fields have been normalized; 0N/A * <code>false</code> otherwise. 0N/A * @exception NullPointerException if the specified 0N/A * <code>date</code> is <code>null</code>