12ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* GENERATED SOURCE. DO NOT MODIFY. */ 2f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// © 2016 and later: Unicode, Inc. and others. 3f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html#License 42ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* 52ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 6bfab1e7fec36dff93fb980c546ad64a565faf9fcPaul Duffin * Copyright (C) 1996-2016, International Business Machines Corporation and 72ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * others. All Rights Reserved. 82ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 92ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpackage android.icu.util; 112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.Date; 122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.Locale; 132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.impl.CalendarCache; 152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.util.ULocale.Category; 162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/** 182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <code>HebrewCalendar</code> is a subclass of <code>Calendar</code> 192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * that that implements the traditional Hebrew calendar. 202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * This is the civil calendar in Israel and the liturgical calendar 212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * of the Jewish faith worldwide. 222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The Hebrew calendar is lunisolar and thus has a number of interesting 242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * properties that distinguish it from the Gregorian. Months start 252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * on the day of (an arithmetic approximation of) each new moon. Since the 262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * solar year (approximately 365.24 days) is not an even multiple of 272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * the lunar month (approximately 29.53 days) an extra "leap month" is 282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * inserted in 7 out of every 19 years. To make matters even more 292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * interesting, the start of a year can be delayed by up to three days 302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in order to prevent certain holidays from falling on the Sabbath and 312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * to prevent certain illegal year lengths. Finally, the lengths of certain 322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * months can vary depending on the number of days in the year. 332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The leap month is known as "Adar 1" and is inserted between the 352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * months of Shevat and Adar in leap years. Since the leap month does 362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * not come at the end of the year, calculations involving 372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * month numbers are particularly complex. Users of this class should 382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * make sure to use the {@link #roll roll} and {@link #add add} methods 392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * rather than attempting to perform date arithmetic by manipulating 402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * the fields directly. 412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <b>Note:</b> In the traditional Hebrew calendar, days start at sunset. 432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * However, in order to keep the time fields in this class 442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * synchronized with those of the other calendars and with local clock time, 452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * we treat days and months as beginning at midnight, 462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * roughly 6 hours after the corresponding sunset. 472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * If you are interested in more information on the rules behind the Hebrew 492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * calendar, see one of the following references: 502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <ul> 512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>"<a href="http://www.amazon.com/exec/obidos/ASIN/0521564743">Calendrical Calculations</a>", 52bfab1e7fec36dff93fb980c546ad64a565faf9fcPaul Duffin * by Nachum Dershowitz & Edward Reingold, Cambridge University Press, 1997, pages 85-91. 532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>Hebrew Calendar Science and Myths, 552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <a href="http://web.archive.org/web/20090423084613/http://www.geocities.com/Athens/1584/"> 562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * http://web.archive.org/web/20090423084613/http://www.geocities.com/Athens/1584/</a> 572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>The Calendar FAQ, 592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <a href="http://www.faqs.org/faqs/calendars/faq/"> 602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * http://www.faqs.org/faqs/calendars/faq/</a> 612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * </ul> 622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * This class should not be subclassed.</p> 652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * HebrewCalendar usually should be instantiated using 672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * {@link android.icu.util.Calendar#getInstance(ULocale)} passing in a <code>ULocale</code> 682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * with the tag <code>"@calendar=hebrew"</code>.</p> 692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @see android.icu.util.GregorianCalendar 712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @see android.icu.util.Calendar 722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @author Laura Werner 742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @author Alan Liu 752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpublic class HebrewCalendar extends Calendar { 772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // jdk1.4.2 serialver 782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final long serialVersionUID = -1952524560588825816L; 792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Tons o' Constants... 822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Tishri, the 1st month of the Hebrew year. 872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int TISHRI = 0; 892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Heshvan, the 2nd month of the Hebrew year. 922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int HESHVAN = 1; 942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Kislev, the 3rd month of the Hebrew year. 972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int KISLEV = 2; 992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Tevet, the 4th month of the Hebrew year. 1022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int TEVET = 3; 1042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Shevat, the 5th month of the Hebrew year. 1072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int SHEVAT = 4; 1092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Adar I, the 6th month of the Hebrew year 1122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * (present in leap years only). In non-leap years, the calendar 1132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * jumps from Shevat (5th month) to Adar (7th month). 1142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int ADAR_1 = 5; 1162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for the Adar, the 7th month of the Hebrew year. 1192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int ADAR = 6; 1212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Nisan, the 8th month of the Hebrew year. 1242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int NISAN = 7; 1262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Iyar, the 9th month of the Hebrew year. 1292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int IYAR = 8; 1312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Sivan, the 10th month of the Hebrew year. 1342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int SIVAN = 9; 1362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Tammuz, the 11th month of the Hebrew year. 1392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int TAMUZ = 10; 1412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Av, the 12th month of the Hebrew year. 1442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int AV = 11; 1462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constant for Elul, the 13th month of the Hebrew year. 1492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final int ELUL = 12; 1512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The absolute date, in milliseconds since 1/1/1970 AD, Gregorian, 1542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * of the start of the Hebrew calendar. In order to keep this calendar's 1552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * time of day in sync with that of the Gregorian calendar, we use 1562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * midnight, rather than sunset the day before. 1572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //private static final long EPOCH_MILLIS = -180799862400000L; // 1/1/1 HY 1592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final int LIMITS[][] = { 1612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Minimum Greatest Least Maximum 1622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Minimum Maximum 1632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 0, 0, 0, 0 }, // ERA 1642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { -5000000, -5000000, 5000000, 5000000 }, // YEAR 1652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 0, 0, 12, 12 }, // MONTH 1662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 1, 1, 51, 56 }, // WEEK_OF_YEAR 1672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // WEEK_OF_MONTH 1682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 1, 1, 29, 30 }, // DAY_OF_MONTH 1692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 1, 1, 353, 385 }, // DAY_OF_YEAR 1702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // DAY_OF_WEEK 1712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { -1, -1, 5, 5 }, // DAY_OF_WEEK_IN_MONTH 1722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // AM_PM 1732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // HOUR 1742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // HOUR_OF_DAY 1752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // MINUTE 1762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // SECOND 1772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // MILLISECOND 1782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // ZONE_OFFSET 1792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // DST_OFFSET 1802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { -5000000, -5000000, 5000000, 5000000 }, // YEAR_WOY 1812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // DOW_LOCAL 1822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { -5000000, -5000000, 5000000, 5000000 }, // EXTENDED_YEAR 1832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // JULIAN_DAY 1842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller {/* */}, // MILLISECONDS_IN_DAY 1852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller }; 1862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 1872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 1882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The lengths of the Hebrew months. This is complicated, because there 1892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * are three different types of years, or six if you count leap years. 1902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Due to the rules for postponing the start of the year to avoid having 1912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * certain holidays fall on the sabbath, the year can end up being three 1922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * different lengths, called "deficient", "normal", and "complete". 1932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 1942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final int MONTH_LENGTH[][] = { 1952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Deficient Normal Complete 1962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, //Tishri 1972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 29, 29, 30 }, //Heshvan 1982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 29, 30, 30 }, //Kislev 1992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 29, 29, 29 }, //Tevet 2002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, //Shevat 2012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, //Adar I (leap years only) 2022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 29, 29, 29 }, //Adar 2032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, //Nisan 2042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 29, 29, 29 }, //Iyar 2052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, //Sivan 2062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 29, 29, 29 }, //Tammuz 2072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, //Av 2082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 29, 29, 29 }, //Elul 2092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller }; 2102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 2122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The cumulative # of days to the end of each month in a non-leap year 2132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Although this can be calculated from the MONTH_LENGTH table, 2142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * keeping it around separately makes some calculations a lot faster 2152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 2162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final int MONTH_START[][] = { 2172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Deficient Normal Complete 2182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 0, 0, 0 }, // (placeholder) 2192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, // Tishri 2202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 59, 59, 60 }, // Heshvan 2212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 88, 89, 90 }, // Kislev 2222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 117, 118, 119 }, // Tevet 2232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 147, 148, 149 }, // Shevat 2242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 147, 148, 149 }, // (Adar I placeholder) 2252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 176, 177, 178 }, // Adar 2262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 206, 207, 208 }, // Nisan 2272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 235, 236, 237 }, // Iyar 2282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 265, 266, 267 }, // Sivan 2292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 294, 295, 296 }, // Tammuz 2302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 324, 325, 326 }, // Av 2312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 353, 354, 355 }, // Elul 2322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller }; 2332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 2352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The cumulative # of days to the end of each month in a leap year 2362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 2372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final int LEAP_MONTH_START[][] = { 2382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Deficient Normal Complete 2392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 0, 0, 0 }, // (placeholder) 2402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 30, 30, 30 }, // Tishri 2412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 59, 59, 60 }, // Heshvan 2422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 88, 89, 90 }, // Kislev 2432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 117, 118, 119 }, // Tevet 2442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 147, 148, 149 }, // Shevat 2452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 177, 178, 179 }, // Adar I 2462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 206, 207, 208 }, // Adar II 2472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 236, 237, 238 }, // Nisan 2482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 265, 266, 267 }, // Iyar 2492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 295, 296, 297 }, // Sivan 2502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 324, 325, 326 }, // Tammuz 2512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 354, 355, 356 }, // Av 2522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 383, 384, 385 }, // Elul 2532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller }; 2542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 2562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Data Members... 2572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 2582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static CalendarCache cache = new CalendarCache(); 2602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 2622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Constructors... 2632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 2642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 2662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a default <code>HebrewCalendar</code> using the current time 2672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the default time zone with the default <code>FORMAT</code> locale. 2682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @see Category#FORMAT 2692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 2702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar() { 2712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT)); 2722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 2752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> based on the current time 2762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the given time zone with the default <code>FORMAT</code> locale. 2772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 2782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param zone The time zone for the new calendar. 2792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @see Category#FORMAT 2802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 2812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(TimeZone zone) { 2822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this(zone, ULocale.getDefault(Category.FORMAT)); 2832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 2862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> based on the current time 2872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the default time zone with the given locale. 2882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 2892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param aLocale The locale for the new calendar. 2902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 2912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(Locale aLocale) { 2922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this(TimeZone.getDefault(), aLocale); 2932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 2942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 2952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 2962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> based on the current time 2972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the default time zone with the given locale. 2982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 2992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param locale The locale for the new calendar. 3002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 3012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(ULocale locale) { 3022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this(TimeZone.getDefault(), locale); 3032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 3042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 3052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 3062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> based on the current time 3072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the given time zone with the given locale. 3082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param zone The time zone for the new calendar. 3102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param aLocale The locale for the new calendar. 3122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 3132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(TimeZone zone, Locale aLocale) { 3142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super(zone, aLocale); 3152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller setTimeInMillis(System.currentTimeMillis()); 3162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 3172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 3182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 3192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> based on the current time 3202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the given time zone with the given locale. 3212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param zone The time zone for the new calendar. 3232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param locale The locale for the new calendar. 3252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 3262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(TimeZone zone, ULocale locale) { 3272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super(zone, locale); 3282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller setTimeInMillis(System.currentTimeMillis()); 3292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 3302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 3312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 3322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> with the given date set 3332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the default time zone with the default <code>FORMAT</code> locale. 3342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param year The value used to set the calendar's {@link #YEAR YEAR} time field. 3362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param month The value used to set the calendar's {@link #MONTH MONTH} time field. 3382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The value is 0-based. e.g., 0 for Tishri. 3392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param date The value used to set the calendar's {@link #DATE DATE} time field. 3412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @see Category#FORMAT 3422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 3432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(int year, int month, int date) { 3442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT)); 3452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(YEAR, year); 3462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(MONTH, month); 3472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(DATE, date); 3482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 3492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 3502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 3512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> with the given date set 3522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in the default time zone with the default <code>FORMAT</code> locale. 3532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param date The date to which the new calendar is set. 3552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @see Category#FORMAT 3562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 3572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(Date date) { 3582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT)); 3592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.setTime(date); 3602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 3612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 3622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 3632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Constructs a <code>HebrewCalendar</code> with the given date 3642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * and time set for the default time zone with the default <code>FORMAT</code> locale. 3652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param year The value used to set the calendar's {@link #YEAR YEAR} time field. 3672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param month The value used to set the calendar's {@link #MONTH MONTH} time field. 3692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The value is 0-based. e.g., 0 for Tishri. 3702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param date The value used to set the calendar's {@link #DATE DATE} time field. 3722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param hour The value used to set the calendar's {@link #HOUR_OF_DAY HOUR_OF_DAY} time field. 3742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param minute The value used to set the calendar's {@link #MINUTE MINUTE} time field. 3762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 3772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param second The value used to set the calendar's {@link #SECOND SECOND} time field. 3782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @see Category#FORMAT 3792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 3802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public HebrewCalendar(int year, int month, int date, int hour, 3812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int minute, int second) 3822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 3832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT)); 3842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(YEAR, year); 3852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(MONTH, month); 3862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(DATE, date); 3872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(HOUR_OF_DAY, hour); 3882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(MINUTE, minute); 3892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller this.set(SECOND, second); 3902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 3912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 3922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 3932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Rolling and adding functions overridden from Calendar 3942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // 3952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // These methods call through to the default implementation in IBMCalendar 3962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // for most of the fields and only handle the unusual ones themselves. 3972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 3982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 3992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 4002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Add a signed amount to a specified field, using this calendar's rules. 4012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * For example, to add three days to the current date, you can call 4022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <code>add(Calendar.DATE, 3)</code>. 4032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 4042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * When adding to certain fields, the values of other fields may conflict and 4052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * need to be changed. For example, when adding one to the {@link #MONTH MONTH} field 4062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * for the date "30 Av 5758", the {@link #DAY_OF_MONTH DAY_OF_MONTH} field 4072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * must be adjusted so that the result is "29 Elul 5758" rather than the invalid 4082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * "30 Elul 5758". 4092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 4102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * This method is able to add to 4112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * all fields except for {@link #ERA ERA}, {@link #DST_OFFSET DST_OFFSET}, 4122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * and {@link #ZONE_OFFSET ZONE_OFFSET}. 4132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 4142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <b>Note:</b> You should always use {@link #roll roll} and add rather 4152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * than attempting to perform arithmetic operations directly on the fields 4162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * of a <tt>HebrewCalendar</tt>. Since the {@link #MONTH MONTH} field behaves 4172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * discontinuously in non-leap years, simple arithmetic can give invalid results. 4182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 4192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param field the time field. 4202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param amount the amount to add to the field. 4212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 4222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @exception IllegalArgumentException if the field is invalid or refers 4232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * to a field that cannot be handled by this method. 4242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 4252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public void add(int field, int amount) 4262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 4272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller switch (field) { 4282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller case MONTH: 4292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 4302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // We can't just do a set(MONTH, get(MONTH) + amount). The 4312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // reason is ADAR_1. Suppose amount is +2 and we land in 4322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // ADAR_1 -- then we have to bump to ADAR_2 aka ADAR. But 4332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // if amount is -2 and we land in ADAR_1, then we have to 4342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // bump the other way -- down to SHEVAT. - Alan 11/00 4352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int month = get(MONTH); 4362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int year = get(YEAR); 4372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller boolean acrossAdar1; 4382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (amount > 0) { 4392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller acrossAdar1 = (month < ADAR_1); // started before ADAR_1? 4402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month += amount; 4412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller for (;;) { 4422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (acrossAdar1 && month>=ADAR_1 && !isLeapYear(year)) { 4432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ++month; 4442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (month <= ELUL) { 4462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 4472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month -= ELUL+1; 4492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ++year; 4502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller acrossAdar1 = true; 4512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } else { 4532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller acrossAdar1 = (month > ADAR_1); // started after ADAR_1? 4542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month += amount; 4552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller for (;;) { 4562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (acrossAdar1 && month<=ADAR_1 && !isLeapYear(year)) { 4572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller --month; 4582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (month >= 0) { 4602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 4612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month += ELUL+1; 4632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller --year; 4642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller acrossAdar1 = true; 4652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller set(MONTH, month); 4682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller set(YEAR, year); 4692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller pinField(DAY_OF_MONTH); 4702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 4712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 4732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller default: 4742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super.add(field, amount); 4752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller break; 4762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 4782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 4792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 4802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Rolls (up/down) a specified amount time on the given field. For 4812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * example, to roll the current date up by three days, you can call 4822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <code>roll(Calendar.DATE, 3)</code>. If the 4832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * field is rolled past its maximum allowable value, it will "wrap" back 4842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * to its minimum and continue rolling. 4852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * For example, calling <code>roll(Calendar.DATE, 10)</code> 4862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * on a Hebrew calendar set to "25 Av 5758" will result in the date "5 Av 5758". 4872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 4882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * When rolling certain fields, the values of other fields may conflict and 4892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * need to be changed. For example, when rolling the {@link #MONTH MONTH} field 4902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * upward by one for the date "30 Av 5758", the {@link #DAY_OF_MONTH DAY_OF_MONTH} field 4912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * must be adjusted so that the result is "29 Elul 5758" rather than the invalid 4922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * "30 Elul". 4932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 4942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * This method is able to roll 4952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * all fields except for {@link #ERA ERA}, {@link #DST_OFFSET DST_OFFSET}, 4962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * and {@link #ZONE_OFFSET ZONE_OFFSET}. Subclasses may, of course, add support for 4972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * additional fields in their overrides of <code>roll</code>. 4982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 4992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <b>Note:</b> You should always use roll and {@link #add add} rather 5002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * than attempting to perform arithmetic operations directly on the fields 5012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * of a <tt>HebrewCalendar</tt>. Since the {@link #MONTH MONTH} field behaves 5022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * discontinuously in non-leap years, simple arithmetic can give invalid results. 5032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 5042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param field the time field. 5052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param amount the amount by which the field should be rolled. 5062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 5072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @exception IllegalArgumentException if the field is invalid or refers 5082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * to a field that cannot be handled by this method. 5092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 5102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public void roll(int field, int amount) 5112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 5122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller switch (field) { 5132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller case MONTH: 5142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 5152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int month = get(MONTH); 5162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int year = get(YEAR); 5172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller boolean leapYear = isLeapYear(year); 5192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int yearLength = monthsInYear(year); 5202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int newMonth = month + (amount % yearLength); 5212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // 5222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If it's not a leap year and we're rolling past the missing month 5232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // of ADAR_1, we need to roll an extra month to make up for it. 5242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // 5252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (!leapYear) { 5262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (amount > 0 && month < ADAR_1 && newMonth >= ADAR_1) { 5272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller newMonth++; 5282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } else if (amount < 0 && month > ADAR_1 && newMonth <= ADAR_1) { 5292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller newMonth--; 5302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 5312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 5322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller set(MONTH, (newMonth + 13) % 13); 5332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller pinField(DAY_OF_MONTH); 5342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return; 5352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 5362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller default: 5372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super.roll(field, amount); 5382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 5392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 5402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 5422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Support methods 5432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 5442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Hebrew date calculations are performed in terms of days, hours, and 5462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds. 5472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final long HOUR_PARTS = 1080; 5482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final long DAY_PARTS = 24*HOUR_PARTS; 5492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // An approximate value for the length of a lunar month. 5512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // It is used to calculate the approximate year and month of a given 5522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // absolute date. 5532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller static private final int MONTH_DAYS = 29; 5542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller static private final long MONTH_FRACT = 12*HOUR_PARTS + 793; 5552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller static private final long MONTH_PARTS = MONTH_DAYS*DAY_PARTS + MONTH_FRACT; 5562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // The time of the new moon (in parts) on 1 Tishri, year 1 (the epoch) 5582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // counting from noon on the day before. BAHARAD is an abbreviation of 5592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Bet (Monday), Hey (5 hours from sunset), Resh-Daled (204). 5602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller static private final long BAHARAD = 11*HOUR_PARTS + 204; 5612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 5632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Finds the day # of the first day in the given Hebrew year. 5642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * To do this, we want to calculate the time of the Tishri 1 new moon 5652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * in that year. 5662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 5672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The algorithm here is similar to ones described in a number of 5682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * references, including: 5692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <ul> 5702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>"Calendrical Calculations", by Nachum Dershowitz & Edward Reingold, 5712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Cambridge University Press, 1997, pages 85-91. 5722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 5732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>Hebrew Calendar Science and Myths, 5742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <a href="http://www.geocities.com/Athens/1584/"> 5752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * http://www.geocities.com/Athens/1584/</a> 5762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 5772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>The Calendar FAQ, 5782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <a href="http://www.faqs.org/faqs/calendars/faq/"> 5792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * http://www.faqs.org/faqs/calendars/faq/</a> 5802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * </ul> 5812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 5822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static long startOfYear(int year) 5832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 5842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller long day = cache.get(year); 5852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (day == CalendarCache.EMPTY) { 5872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int months = (235 * year - 234) / 19; // # of months before year 5882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller long frac = months * MONTH_FRACT + BAHARAD; // Fractional part of day # 5902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller day = months * 29 + (frac / DAY_PARTS); // Whole # part of calculation 5912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller frac = frac % DAY_PARTS; // Time of day 5922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int wd = (int)(day % 7); // Day of week (0 == Monday) 5942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 5952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (wd == 2 || wd == 4 || wd == 6) { 5962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If the 1st is on Sun, Wed, or Fri, postpone to the next day 5972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller day += 1; 5982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller wd = (int)(day % 7); 5992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (wd == 1 && frac > 15*HOUR_PARTS+204 && !isLeapYear(year) ) { 6012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If the new moon falls after 3:11:20am (15h204p from the previous noon) 6022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // on a Tuesday and it is not a leap year, postpone by 2 days. 6032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // This prevents 356-day years. 6042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller day += 2; 6052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller else if (wd == 0 && frac > 21*HOUR_PARTS+589 && isLeapYear(year-1) ) { 6072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If the new moon falls after 9:32:43 1/3am (21h589p from yesterday noon) 6082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // on a Monday and *last* year was a leap year, postpone by 1 day. 6092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Prevents 382-day years. 6102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller day += 1; 6112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller cache.put(year, day); 6132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return day; 6152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /* 6182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Find the day of the week for a given day 6192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 6202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param day The # of days since the start of the Hebrew calendar, 6212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 1-based (i.e. 1/1/1 AM is day 1). 6222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 6232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /*private static int absoluteDayToDayOfWeek(long day) 6242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 6252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // We know that 1/1/1 AM is a Monday, which makes the math easy... 6262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return (int)(day % 7) + 1; 6272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller }*/ 6282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 6302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Returns the the type of a given year. 6312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 0 "Deficient" year with 353 or 383 days 6322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 1 "Normal" year with 354 or 384 days 6332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 2 "Complete" year with 355 or 385 days 6342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 6352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private final int yearType(int year) 6362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller { 6372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int yearLength = handleGetYearLength(year); 6382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (yearLength > 380) { 6402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller yearLength -= 30; // Subtract length of leap month. 6412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int type = 0; 6442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller switch (yearLength) { 6462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller case 353: 6472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller type = 0; break; 6482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller case 354: 6492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller type = 1; break; 6502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller case 355: 6512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller type = 2; break; 6522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller default: 6532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller throw new IllegalArgumentException("Illegal year length " + yearLength + " in year " + year); 6542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return type; 6572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 6602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Determine whether a given Hebrew year is a leap year 6612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 6622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The rule here is that if (year % 19) == 0, 3, 6, 8, 11, 14, or 17. 6632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * The formula below performs the same test, believe it or not. 6642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @deprecated This API is ICU internal only. 66593cf604e9dd0525f15bc0a7450b2a35f3884c298Neil Fuller * @hide original deprecated declaration 666836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide draft / provisional / internal are hidden on Android 6672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 6682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller @Deprecated 6692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static boolean isLeapYear(int year) { 6702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //return (year * 12 + 17) % 19 >= 12; 6712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int x = (year*12 + 17) % 19; 6722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return x >= ((x < 0) ? -7 : 12); 6732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static int monthsInYear(int year) { 6762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return isLeapYear(year) ? 13 : 12; 6772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 6802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Calendar framework 6812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 6822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 6842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 6852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller protected int handleGetLimit(int field, int limitType) { 6862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return LIMITS[field][limitType]; 6872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 6882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 6892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 6902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Returns the length of the given month in the given year 6912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 6922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller protected int handleGetMonthLength(int extendedYear, int month) { 6932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Resolve out-of-range months. This is necessary in order to 6942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // obtain the correct year. We correct to 6952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // a 12- or 13-month year (add/subtract 12 or 13, depending 6962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // on the year) but since we _always_ number from 0..12, and 6972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // the leap year determines whether or not month 5 (Adar 1) 6982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // is present, we allow 0..12 in any given year. 6992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while (month < 0) { 7002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month += monthsInYear(--extendedYear); 7012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Careful: allow 0..12 in all years 7032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while (month > 12) { 7042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month -= monthsInYear(extendedYear++); 7052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller switch (month) { 7082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller case HESHVAN: 7092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller case KISLEV: 7102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // These two month lengths can vary 7112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return MONTH_LENGTH[month][yearType(extendedYear)]; 7122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller default: 7142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // The rest are a fixed length 7152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return MONTH_LENGTH[month][0]; 7162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 7202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Returns the number of days in the given Hebrew year 7212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 7222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller protected int handleGetYearLength(int eyear) { 7232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return (int)(startOfYear(eyear+1) - startOfYear(eyear)); 7242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 7272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * {@inheritDoc} 7282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p> 7292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Overrides {@link Calendar#validateField(int)} to provide 7302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * special handling for month validation for Hebrew calendar. 7312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @deprecated This API is ICU internal only. 73293cf604e9dd0525f15bc0a7450b2a35f3884c298Neil Fuller * @hide original deprecated declaration 733836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide draft / provisional / internal are hidden on Android 7342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 7352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller @Deprecated 7362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller protected void validateField(int field) { 7372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (field == MONTH && !isLeapYear(handleGetExtendedYear()) && internalGet(MONTH) == ADAR_1) { 7382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller throw new IllegalArgumentException("MONTH cannot be ADAR_1(5) except leap years"); 7392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller super.validateField(field); 7422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 7452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Functions for converting from milliseconds to field values 7462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 7472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 7492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Subclasses may override this method to compute several fields 7502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * specific to each calendar system. These are: 7512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 7522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <ul><li>ERA 7532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>YEAR 7542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>MONTH 7552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>DAY_OF_MONTH 7562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>DAY_OF_YEAR 7572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <li>EXTENDED_YEAR</ul> 7582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 7592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, 7602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * which will be set when this method is called. Subclasses can 7612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * also call the getGregorianXxx() methods to obtain Gregorian 7622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * calendar equivalents for the given Julian day. 7632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * 7642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <p>In addition, subclasses should compute any subclass-specific 7652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * fields, that is, fields from BASE_FIELD_COUNT to 7662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * getFieldCount() - 1. 7672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 7682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller protected void handleComputeFields(int julianDay) { 7692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller long d = julianDay - 347997; 7702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller long m = (d * DAY_PARTS) / MONTH_PARTS; // Months (approx) 7712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int year = (int)((19 * m + 234) / 235) + 1; // Years (approx) 7722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller long ys = startOfYear(year); // 1st day of year 7732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int dayOfYear = (int)(d - ys); 7742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Because of the postponement rules, it's possible to guess wrong. Fix it. 7762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while (dayOfYear < 1) { 7772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller year--; 7782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ys = startOfYear(year); 7792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller dayOfYear = (int)(d - ys); 7802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Now figure out which month we're in, and the date within that month 7832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int yearType = yearType(year); 7842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int monthStart[][] = isLeapYear(year) ? LEAP_MONTH_START : MONTH_START; 7852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int month = 0; 7872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while (dayOfYear > monthStart[month][yearType]) { 7882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month++; 7892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 7902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month--; 7912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int dayOfMonth = dayOfYear - monthStart[month][yearType]; 7922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 7932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller internalSet(ERA, 0); 7942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller internalSet(YEAR, year); 7952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller internalSet(EXTENDED_YEAR, year); 7962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller internalSet(MONTH, month); 7972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller internalSet(DAY_OF_MONTH, dayOfMonth); 7982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller internalSet(DAY_OF_YEAR, dayOfYear); 7992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 8022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Functions for converting from field values to milliseconds 8032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller //------------------------------------------------------------------------- 8042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 8062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 8072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller protected int handleGetExtendedYear() { 8082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller int year; 8092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (newerField(EXTENDED_YEAR, YEAR) == EXTENDED_YEAR) { 8102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller year = internalGet(EXTENDED_YEAR, 1); // Default to year 1 8112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } else { 8122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller year = internalGet(YEAR, 1); // Default to year 1 8132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return year; 8152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 8182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Return JD of start of given month/year. 8192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 8202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller protected int handleComputeMonthStart(int eyear, int month, boolean useMonth) { 8212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Resolve out-of-range months. This is necessary in order to 8232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // obtain the correct year. We correct to 8242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // a 12- or 13-month year (add/subtract 12 or 13, depending 8252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // on the year) but since we _always_ number from 0..12, and 8262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // the leap year determines whether or not month 5 (Adar 1) 8272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // is present, we allow 0..12 in any given year. 8282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while (month < 0) { 8292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month += monthsInYear(--eyear); 8302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Careful: allow 0..12 in all years 8322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller while (month > 12) { 8332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller month -= monthsInYear(eyear++); 8342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller long day = startOfYear(eyear); 8372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (month != 0) { 8392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (isLeapYear(eyear)) { 8402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller day += LEAP_MONTH_START[month][yearType(eyear)]; 8412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } else { 8422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller day += MONTH_START[month][yearType(eyear)]; 8432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return (int) (day + 347997); 8472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 8502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * {@inheritDoc} 8512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 8522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public String getType() { 8532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return "hebrew"; 8542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /* 8572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static CalendarFactory factory; 8582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static CalendarFactory factory() { 8592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (factory == null) { 8602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller factory = new CalendarFactory() { 8612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public Calendar create(TimeZone tz, ULocale loc) { 8622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return new HebrewCalendar(tz, loc); 8632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 8652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public String factoryName() { 8662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return "Hebrew"; 8672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller }; 8692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return factory; 8712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 8722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 8732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller} 874