2362N/A * Copyright (c) 2003, 2004, 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 * The <code>BaseCalendar</code> provides basic calendar calculation 0N/A * functions to support the Julian, Gregorian, and Gregorian-based 0N/A * @author Masayoshi Okutsu 0N/A public static final int MAY =
5;
0N/A // day of week constants 0N/A // The base Gregorian year of FIXED_DATES[] 0N/A // Pre-calculated fixed dates of January 1 from BASE_YEAR 0N/A // (Gregorian). This table covers all the years that can be 0N/A // supported by the POSIX time_t (32-bit) after the Epoch. Note 0N/A // that the data type is int[]. 0N/A // Cache for the fixed date of January 1 and year length of the 0N/A // cachedYear. A simple benchmark showed 7% performance 0N/A // improvement with >90% cache hit. The initial values are for Gregorian. 0N/A // If the date has a time zone, then we need to recalculate 0N/A // the calendar fields. Let getTime() do it. 0N/A if (!(d >
0 && d <=
ml)) {
0N/A if (d <=
0 && d > -
28) {
0N/A }
else if (d >
ml && d < (
ml +
28)) {
0N/A * Returns 366 if the specified date is in a leap year, or 365 0N/A * otherwise This method does not perform the normalization with 0N/A * the specified <code>CalendarDate</code>. The 0N/A * <code>CalendarDate</code> must be normalized to get a correct 0N/A * @param a <code>CalendarDate</code> 0N/A * @return a year length in days 0N/A * @throws ClassCastException if the specified date is not a 0N/A * {@link BaseCalendar.Date} 0N/A // 12 1 2 3 4 5 6 7 8 9 10 11 12 0N/A = {
31,
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31};
0N/A // 12/1 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 10/1 11/1 12/1 0N/A = { -
30,
0,
31,
59,
90,
120,
151,
181,
212,
243,
273,
304,
334};
0N/A // 12/1 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 10/1 11/1 12/1 0N/A = { -
30,
0,
31,
59+
1,
90+
1,
120+
1,
151+
1,
181+
1,
212+
1,
243+
1,
273+
1,
304+
1,
334+
1};
0N/A // accepts 0 (December in the previous year) to 12. 0N/A // public for java.util.GregorianCalendar 0N/A // Look up the one year cache 0N/A // Look up the pre-calculated fixed date table 0N/A // If it's January 1, update the cache. 0N/A * Calculates calendar fields and store them in the specified 0N/A * <code>CalendarDate</code>. 0N/A // should be 'protected' 0N/A // Looking up FIXED_DATES[] here didn't improve performance 0N/A // much. So we calculate year and jan1. getFixedDate() 0N/A // will look up FIXED_DATES[] actually. 0N/A // Update the cache data 0N/A * Returns the day of week of the given Gregorian date. 0N/A // The fixed day 1 (January 1, 1 Gregorian) is Monday. 0N/A * Returns the Gregorian year number of the given fixed date. 0N/A * @return true if the specified year is a Gregorian leap year, or 0N/A * @see BaseCalendar#isGregorianLeapYear