HebrewCalendar is a subclass of Calendar
that that implements the traditional Hebrew calendar.
This is the civil calendar in Israel and the liturgical calendar
of the Jewish faith worldwide.
The Hebrew calendar is lunisolar and thus has a number of interesting properties that distinguish it from the Gregorian. Months start on the day of (an arithmetic approximation of) each new moon. Since the solar year (approximately 365.24 days) is not an even multiple of the lunar month (approximately 29.53 days) an extra "leap month" is inserted in 7 out of every 19 years. To make matters even more interesting, the start of a year can be delayed by up to three days in order to prevent certain holidays from falling on the Sabbath and to prevent certain illegal year lengths. Finally, the lengths of certain months can vary depending on the number of days in the year.
The leap month is known as "Adar 1" and is inserted between the
months of Shevat and Adar in leap years. Since the leap month does
not come at the end of the year, calculations involving
month numbers are particularly complex. Users of this class should
make sure to use the roll and add methods
rather than attempting to perform date arithmetic by manipulating
the fields directly.
Note
In the traditional Hebrew calendar, days start at sunset. However, in order to keep the time fields in this class synchronized with those of the other calendars and with local clock time, we treat days and months as beginning at midnight, roughly 6 hours after the corresponding sunset.
If you are interested in more information on the rules behind the Hebrew calendar, see one of the following references:
This class should not be subclassed.
HebrewCalendar usually should be instantiated using
com. passing in a ULocale
with the tag "@calendar=hebrew".
com.ibm.icu.util.GregorianCalendar , com.ibm.icu.util.Calendar
| Modifier and Type | Field and Description |
|---|---|
| public static final int | ADAR
Constant for the Adar, the 7th month of the Hebrew year. |
| public static final int | ADAR_1
Constant for Adar I, the 6th month of the Hebrew year (present in leap years only). |
| public static final int | AV
Constant for Av, the 12th month of the Hebrew year. |
| private static final long | |
| private static CalendarCache | |
| private static final long | |
| public static final int | ELUL
Constant for Elul, the 13th month of the Hebrew year. |
| private static String[] | |
| public static final int | HESHVAN
Constant for Heshvan, the 2nd month of the Hebrew year. |
| private static final long | |
| public static final int | IYAR
Constant for Iyar, the 9th month of the Hebrew year. |
| public static final int | KISLEV
Constant for Kislev, the 3rd month of the Hebrew year. |
| private static final int[][] | LEAP_MONTH_START
The cumulative # of days to the end of each month in a leap year |
| private static final int[][] | LIMITS
The absolute date, in milliseconds since 1/1/1970 AD, Gregorian,
of the start of the Hebrew calendar.
|
| private static final int | |
| private static final long | |
| private static final int[][] | MONTH_LENGTH
The lengths of the Hebrew months. |
| private static final long | |
| private static final int[][] | MONTH_START
The cumulative # of days to the end of each month in a non-leap year Although this can be calculated from the MONTH_LENGTH table, keeping it around separately makes some calculations a lot faster |
| public static final int | NISAN
Constant for Nisan, the 8th month of the Hebrew year. |
| private static final long | |
| public static final int | SHEVAT
Constant for Shevat, the 5th month of the Hebrew year. |
| public static final int | SIVAN
Constant for Sivan, the 10th month of the Hebrew year. |
| public static final int | TAMUZ
Constant for Tammuz, the 11th month of the Hebrew year. |
| public static final int | TEVET
Constant for Tevet, the 4th month of the Hebrew year. |
| public static final int | TISHRI
Constant for Tishri, the 1st month of the Hebrew year. |
| Access | Constructor and Description |
|---|---|
| public | HebrewCalendar()
Constructs a default |
| public | HebrewCalendar(TimeZone
The time zone for the new calendar. zone)Constructs a |
| public | HebrewCalendar(Locale
The locale for the new calendar. aLocale)Constructs a |
| public | HebrewCalendar(ULocale
The locale for the new calendar. locale)Constructs a |
| public | HebrewCalendar(TimeZone
The time zone for the new calendar. zone, Locale The locale for the new calendar. aLocale)Constructs a |
| public | HebrewCalendar(TimeZone
The time zone for the new calendar. zone, ULocale The locale for the new calendar. locale)Constructs a |
| public | HebrewCalendar(int
The value used to set the calendar's year, int YEAR time field.The value used to set the calendar's month, int MONTH time field.
The value is 0-based. e.g., 0 for Tishri.The value used to set the calendar's date)DATE time field.Constructs a |
| public | HebrewCalendar(Date
The date to which the new calendar is set. date)Constructs a |
| public | HebrewCalendar(int
The value used to set the calendar's year, int YEAR time field.The value used to set the calendar's month, int MONTH time field.
The value is 0-based. e.g., 0 for Tishri.The value used to set the calendar's date, int DATE time field.The value used to set the calendar's hour, int HOUR_OF_DAY time field.The value used to set the calendar's minute, int MINUTE time field.The value used to set the calendar's second)SECOND time field.Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(int
the time field. field, int the amount to add to the field. amount)Overrides com. |
| public String | Returns: One of 13 possible strings in {"M01".. "M05", "M05L", "M06" .. "M12"}. |
| public String | |
| protected void | handleComputeFields(int julianDay)
Subclasses may override this method to compute several fields
specific to each calendar system.
|
| protected int | handleComputeMonthStart(int
the extended year eyear, int the zero-based month, or 0 if useMonth is false month, boolean if false, compute the day before the first day of
the given year, otherwise, compute the day before the first day of
the given month useMonth)Implements abstract com. |
| protected int | handleGetExtendedYear()
Implements abstract com. |
| protected int | handleGetLimit(int
one of the above field numbers field, int one of limitType)MINIMUM, GREATEST_MINIMUM,
LEAST_MAXIMUM, or MAXIMUMImplements abstract com. |
| protected int | handleGetMonthLength(int extendedYear, int month)
Returns the length of the given month in the given year
|
| protected int | handleGetYearLength(int eyear)
Returns the number of days in the given Hebrew year
|
| public boolean | |
| protected int | internalGetMonth()
Overrides com.
Deprecated
This API is ICU internal only.
Use this function instead of internalGet(MONTH).
|
| public static boolean | isLeapYear(int year)
Deprecated
This API is ICU internal only.
Determine whether a given Hebrew year is a leap year
The rule here is that if (year % 19) == 0, 3, 6, 8, 11, 14, or 17.
|
| private static int | |
| public void | roll(int
the time field. field, int the amount by which the field should be rolled. amount)Overrides com. |
| public void | setTemporalMonthCode(String
The value to be set for temporal monthCode. temporalMonth)
Sets The Temporal monthCode which is a string identifier that starts
with the literal grapheme "M" followed by two graphemes representing
the zero-padded month number of the current month in a normal
(non-leap) year and suffixed by an optional literal grapheme "L" if this
is a leap month in a lunisolar calendar.
|
| private static long | |
| protected void | validateField(int field)
Overrides com.
Deprecated
This API is ICU internal only.
Validate a single field of this calendar.
|
| private final int |
| ADAR | back to summary |
|---|---|
| public static final int ADAR Constant for the Adar, the 7th month of the Hebrew year.
| |
| ADAR_1 | back to summary |
|---|---|
| public static final int ADAR_1 Constant for Adar I, the 6th month of the Hebrew year (present in leap years only). In non-leap years, the calendar jumps from Shevat (5th month) to Adar (7th month).
| |
| AV | back to summary |
|---|---|
| public static final int AV Constant for Av, the 12th month of the Hebrew year.
| |
| BAHARAD | back to summary |
|---|---|
| private static final long BAHARAD | |
| cache | back to summary |
|---|---|
| private static CalendarCache cache | |
| DAY_PARTS | back to summary |
|---|---|
| private static final long DAY_PARTS | |
| ELUL | back to summary |
|---|---|
| public static final int ELUL Constant for Elul, the 13th month of the Hebrew year.
| |
| gTemporalMonthCodesForHebrew | back to summary |
|---|---|
| private static String[] gTemporalMonthCodesForHebrew | |
| HESHVAN | back to summary |
|---|---|
| public static final int HESHVAN Constant for Heshvan, the 2nd month of the Hebrew year.
| |
| HOUR_PARTS | back to summary |
|---|---|
| private static final long HOUR_PARTS | |
| IYAR | back to summary |
|---|---|
| public static final int IYAR Constant for Iyar, the 9th month of the Hebrew year.
| |
| KISLEV | back to summary |
|---|---|
| public static final int KISLEV Constant for Kislev, the 3rd month of the Hebrew year.
| |
| LEAP_MONTH_START | back to summary |
|---|---|
| private static final int[][] LEAP_MONTH_START The cumulative # of days to the end of each month in a leap year | |
| LIMITS | back to summary |
|---|---|
| private static final int[][] LIMITS Hides com. The absolute date, in milliseconds since 1/1/1970 AD, Gregorian, of the start of the Hebrew calendar. In order to keep this calendar's time of day in sync with that of the Gregorian calendar, we use midnight, rather than sunset the day before. | |
| MONTH_DAYS | back to summary |
|---|---|
| private static final int MONTH_DAYS | |
| MONTH_FRACT | back to summary |
|---|---|
| private static final long MONTH_FRACT | |
| MONTH_LENGTH | back to summary |
|---|---|
| private static final int[][] MONTH_LENGTH The lengths of the Hebrew months. This is complicated, because there are three different types of years, or six if you count leap years. Due to the rules for postponing the start of the year to avoid having certain holidays fall on the sabbath, the year can end up being three different lengths, called "deficient", "normal", and "complete". | |
| MONTH_PARTS | back to summary |
|---|---|
| private static final long MONTH_PARTS | |
| MONTH_START | back to summary |
|---|---|
| private static final int[][] MONTH_START The cumulative # of days to the end of each month in a non-leap year Although this can be calculated from the MONTH_LENGTH table, keeping it around separately makes some calculations a lot faster | |
| NISAN | back to summary |
|---|---|
| public static final int NISAN Constant for Nisan, the 8th month of the Hebrew year.
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| SHEVAT | back to summary |
|---|---|
| public static final int SHEVAT Constant for Shevat, the 5th month of the Hebrew year.
| |
| SIVAN | back to summary |
|---|---|
| public static final int SIVAN Constant for Sivan, the 10th month of the Hebrew year.
| |
| TAMUZ | back to summary |
|---|---|
| public static final int TAMUZ Constant for Tammuz, the 11th month of the Hebrew year.
| |
| TEVET | back to summary |
|---|---|
| public static final int TEVET Constant for Tevet, the 4th month of the Hebrew year.
| |
| TISHRI | back to summary |
|---|---|
| public static final int TISHRI Constant for Tishri, the 1st month of the Hebrew year.
| |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar() Constructs a default
| |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(TimeZone zone) Constructs a
| |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(Locale aLocale) Constructs a | |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(ULocale locale) Constructs a | |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(TimeZone zone, Locale aLocale) Constructs a | |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(TimeZone zone, ULocale locale) Constructs a | |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(int year, int month, int date) Constructs a
| |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(Date date) Constructs a
| |
| HebrewCalendar | back to summary |
|---|---|
| public HebrewCalendar(int year, int month, int date, int hour, int minute, int second) Constructs a
| |
| add | back to summary |
|---|---|
| public void add(int field, int amount) Overrides com. Add a signed amount to a specified field, using this calendar's rules.
For example, to add three days to the current date, you can call
When adding to certain fields, the values of other fields may conflict and
need to be changed. For example, when adding one to the
This method is able to add to
all fields except for Note You should always use
| |
| getTemporalMonthCode | back to summary |
|---|---|
| public String getTemporalMonthCode() Overrides com. Gets The Temporal monthCode value corresponding to the month for the date. The value is a string identifier that starts with the literal grapheme "M" followed by two graphemes representing the zero-padded month number of the current month in a normal (non-leap) year and suffixed by an optional literal grapheme "L" if this is a leap month in a lunisolar calendar. For the Hebrew calendar, the values are "M01" .. "M12" for non-leap year, and "M01" .. "M05", "M05L", "M06" .. "M12" for leap year. | |
| getType | back to summary |
|---|---|
| public String getType() Overrides com. Doc from com. ICU See type="old type name" for the calendar attribute of locale IDs at http://www.unicode.org/reports/tr35/#Key_Type_Definitions | |
| handleComputeFields | back to summary |
|---|---|
| protected void handleComputeFields(int julianDay) Overrides com. Subclasses may override this method to compute several fields specific to each calendar system. These are:
In addition, subclasses should compute any subclass-specific fields, that is, fields from BASE_FIELD_COUNT to getFieldCount() - 1. | |
| handleComputeMonthStart | back to summary |
|---|---|
| protected int handleComputeMonthStart(int eyear, int month, boolean useMonth) Implements abstract com. Return JD of start of given month/year.
| |
| handleGetExtendedYear | back to summary |
|---|---|
| protected int handleGetExtendedYear() Implements abstract com. Doc from com. Returns the extended year defined by the current fields. This will use the EXTENDED_YEAR field or the YEAR and supra-year fields (such as ERA) specific to the calendar system, depending on which set of fields is newer. | |
| handleGetLimit | back to summary |
|---|---|
| protected int handleGetLimit(int field, int limitType) Implements abstract com. Doc from com. Subclass API for defining limits of different types. Subclasses must implement this method to return limits for the following fields: ERA YEAR MONTH WEEK_OF_YEAR WEEK_OF_MONTH DAY_OF_MONTH DAY_OF_YEAR DAY_OF_WEEK_IN_MONTH YEAR_WOY EXTENDED_YEAR | |
| handleGetMonthLength | back to summary |
|---|---|
| protected int handleGetMonthLength(int extendedYear, int month) Overrides com. Returns the length of the given month in the given year | |
| handleGetYearLength | back to summary |
|---|---|
| protected int handleGetYearLength(int eyear) Overrides com. Returns the number of days in the given Hebrew year | |
| inTemporalLeapYear | back to summary |
|---|---|
| public boolean inTemporalLeapYear() Overrides com. Doc from com. ICU
| |
| internalGetMonth | back to summary |
|---|---|
| protected int internalGetMonth() Overrides com. Doc from com. Deprecated This API is ICU internal only. Use this function instead of internalGet(MONTH). The implementation check the timestamp of MONTH and ORDINAL_MONTH and use the one set later. The subclass should override it to conver the value of ORDINAL_MONTH to MONTH correctly if ORDINAL_MONTH has higher priority.
| |
| isLeapYear | back to summary |
|---|---|
| public static boolean isLeapYear(int year)
Deprecated This API is ICU internal only. Determine whether a given Hebrew year is a leap year The rule here is that if (year % 19) == 0, 3, 6, 8, 11, 14, or 17. The formula below performs the same test, believe it or not.
| |
| monthsInYear | back to summary |
|---|---|
| private static int monthsInYear(int year) | |
| roll | back to summary |
|---|---|
| public void roll(int field, int amount) Overrides com. Rolls (up/down) a specified amount time on the given field. For
example, to roll the current date up by three days, you can call
When rolling certain fields, the values of other fields may conflict and
need to be changed. For example, when rolling the
This method is able to roll
all fields except for Note You should always use roll and
| |
| setTemporalMonthCode | back to summary |
|---|---|
| public void setTemporalMonthCode(String temporalMonth) Overrides com. Sets The Temporal monthCode which is a string identifier that starts with the literal grapheme "M" followed by two graphemes representing the zero-padded month number of the current month in a normal (non-leap) year and suffixed by an optional literal grapheme "L" if this is a leap month in a lunisolar calendar. For Hebrew calendar, the values are "M01" .. "M12" for non-leap years, and "M01" .. "M05", "M05L", "M06" .. "M12" for leap year. | |
| startOfYear | back to summary |
|---|---|
| private static long startOfYear(int year) Finds the day # of the first day in the given Hebrew year. To do this, we want to calculate the time of the Tishri 1 new moon in that year. The algorithm here is similar to ones described in a number of references, including:
| |
| validateField | back to summary |
|---|---|
| protected void validateField(int field) Overrides com. Doc from com. Deprecated This API is ICU internal only. Validate a single field of this calendar. Subclasses should
override this method to validate any calendar-specific fields.
Generic fields can be handled by
Overrides
| |
| yearType | back to summary |
|---|---|
| private final int yearType(int year) Returns the the type of a given year. 0 "Deficient" year with 353 or 383 days 1 "Normal" year with 354 or 384 days 2 "Complete" year with 355 or 385 days | |