Class HebrewCalendar
- java.lang.Object
-
- com.ibm.icu.util.Calendar
-
- com.ibm.icu.util.HebrewCalendar
-
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Calendar>
public class HebrewCalendar extends Calendar
HebrewCalendaris a subclass ofCalendarthat 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 two 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
rollandaddmethods 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:
- "Calendrical Calculations", by Nachum Dershowitz & Edward Reingold, Cambridge University Press, 1997, pages 85-91.
- Hebrew Calendar Science and Myths, http://web.archive.org/web/20090423084613/http://www.geocities.com/Athens/1584/
- The Calendar FAQ, http://www.faqs.org/faqs/calendars/faq/
This class should not be subclassed.
HebrewCalendar usually should be instantiated using
Calendar.getInstance(ULocale)passing in aULocalewith the tag"@calendar=hebrew".- Author:
- Laura Werner, Alan Liu
- See Also:
GregorianCalendar,Calendar, Serialized Form- Status:
- Stable ICU 2.8.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.icu.util.Calendar
Calendar.FormatConfiguration, Calendar.WeekData
-
-
Field Summary
Fields Modifier and Type Field Description static intADARConstant for the Adar, the 7th month of the Hebrew year.static intADAR_1Constant for Adar I, the 6th month of the Hebrew year (present in leap years only).static intAVConstant for Av, the 12th month of the Hebrew year.static intELULConstant for Elul, the 13th month of the Hebrew year.static intHESHVANConstant for Heshvan, the 2nd month of the Hebrew year.static intIYARConstant for Iyar, the 9th month of the Hebrew year.static intKISLEVConstant for Kislev, the 3rd month of the Hebrew year.static intNISANConstant for Nisan, the 8th month of the Hebrew year.static intSHEVATConstant for Shevat, the 5th month of the Hebrew year.static intSIVANConstant for Sivan, the 10th month of the Hebrew year.static intTAMUZConstant for Tammuz, the 11th month of the Hebrew year.static intTEVETConstant for Tevet, the 4th month of the Hebrew year.static intTISHRIConstant for Tishri, the 1st month of the Hebrew year.-
Fields inherited from class com.ibm.icu.util.Calendar
AM, AM_PM, APRIL, AUGUST, BASE_FIELD_COUNT, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DOW_LOCAL, DST_OFFSET, EPOCH_JULIAN_DAY, ERA, EXTENDED_YEAR, FEBRUARY, FRIDAY, GREATEST_MINIMUM, HOUR, HOUR_OF_DAY, INTERNALLY_SET, IS_LEAP_MONTH, JAN_1_1_JULIAN_DAY, JANUARY, JULIAN_DAY, JULY, JUNE, LEAST_MAXIMUM, MARCH, MAX_DATE, MAX_FIELD_COUNT, MAX_JULIAN, MAX_MILLIS, MAXIMUM, MAY, MILLISECOND, MILLISECONDS_IN_DAY, MIN_DATE, MIN_JULIAN, MIN_MILLIS, MINIMUM, MINIMUM_USER_STAMP, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ORDINAL_MONTH, PM, RESOLVE_REMAP, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, UNSET, WALLTIME_FIRST, WALLTIME_LAST, WALLTIME_NEXT_VALID, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, WEEKDAY, WEEKEND, WEEKEND_CEASE, WEEKEND_ONSET, YEAR, YEAR_WOY, ZONE_OFFSET
-
-
Constructor Summary
Constructors Constructor Description HebrewCalendar()Constructs a defaultHebrewCalendarusing the current time in the default time zone with the defaultFORMATlocale.HebrewCalendar(int year, int month, int date)Constructs aHebrewCalendarwith the given date set in the default time zone with the defaultFORMATlocale.HebrewCalendar(int year, int month, int date, int hour, int minute, int second)Constructs aHebrewCalendarwith the given date and time set for the default time zone with the defaultFORMATlocale.HebrewCalendar(TimeZone zone)Constructs aHebrewCalendarbased on the current time in the given time zone with the defaultFORMATlocale.HebrewCalendar(TimeZone zone, ULocale locale)Constructs aHebrewCalendarbased on the current time in the given time zone with the given locale.HebrewCalendar(TimeZone zone, Locale aLocale)Constructs aHebrewCalendarbased on the current time in the given time zone with the given locale.HebrewCalendar(ULocale locale)Constructs aHebrewCalendarbased on the current time in the default time zone with the given locale.HebrewCalendar(Date date)Constructs aHebrewCalendarwith the given date set in the default time zone with the defaultFORMATlocale.HebrewCalendar(Locale aLocale)Constructs aHebrewCalendarbased on the current time in the default time zone with the given locale.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int field, int amount)Add a signed amount to a specified field, using this calendar's rules.protected intgetRelatedYearDifference()Deprecated.This API is ICU internal only.StringgetTemporalMonthCode()Gets The Temporal monthCode value corresponding to the month for the date.StringgetType()[icu] Returns the calendar type name string for this Calendar object.protected voidhandleComputeFields(int julianDay)Subclasses may override this method to compute several fields specific to each calendar system.protected inthandleComputeMonthStart(int eyear, int month, boolean useMonth)Return JD of start of given month/year.protected inthandleGetExtendedYear()Returns the extended year defined by the current fields.protected inthandleGetLimit(int field, int limitType)Subclass API for defining limits of different types.protected inthandleGetMonthLength(int extendedYear, int month)Returns the length of the given month in the given yearprotected inthandleGetYearLength(int eyear)Returns the number of days in the given Hebrew yearbooleaninTemporalLeapYear()[icu] Returns true if the date is in a leap year.protected intinternalGetMonth()Deprecated.This API is ICU internal only.static booleanisLeapYear(int year)Deprecated.This API is ICU internal only.voidroll(int field, int amount)Rolls (up/down) a specified amount time on the given field.voidsetTemporalMonthCode(String 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.protected voidvalidateField(int field)Deprecated.This API is ICU internal only.-
Methods inherited from class com.ibm.icu.util.Calendar
after, before, clear, clear, clone, compareTo, complete, computeFields, computeGregorianFields, computeGregorianMonthStart, computeJulianDay, computeMillisInDay, computeMillisInDayLong, computeTime, computeZoneOffset, computeZoneOffset, equals, fieldDifference, fieldName, floorDivide, floorDivide, floorDivide, floorDivide, get, getActualMaximum, getActualMinimum, getAvailableLocales, getAvailableULocales, getDateAtTimePattern, getDateTimeFormat, getDateTimeFormat, getDateTimePattern, getDayOfWeekType, getDefaultDayInMonth, getDefaultMonthInYear, getDisplayName, getDisplayName, getFieldCount, getFieldResolutionTable, getFirstDayOfWeek, getGreatestMinimum, getGregorianDayOfMonth, getGregorianDayOfYear, getGregorianMonth, getGregorianYear, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getKeywordValuesForLocale, getLeastMaximum, getLimit, getLocale, getMaximum, getMinimalDaysInFirstWeek, getMinimum, getRelatedYear, getRepeatedWallTimeOption, getSkippedWallTimeOption, getStamp, getTime, getTimeInMillis, getTimeZone, getWeekData, getWeekDataForRegion, getWeekendTransition, gregorianMonthLength, gregorianPreviousMonthLength, handleComputeJulianDay, handleCreateFields, handleGetDateFormat, handleGetDateFormat, handleGetDateFormat, handleGetDateFormat, hashCode, haveDefaultCentury, internalGet, internalGet, internalGetMonth, internalGetTimeInMillis, internalSet, isEquivalentTo, isEra0CountingBackward, isGregorianLeapYear, isLenient, isSet, isWeekend, isWeekend, julianDayToDayOfWeek, julianDayToMillis, millisToJulianDay, newerField, newestStamp, pinField, prepareGetActual, resolveFields, roll, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setRelatedYear, setRepeatedWallTimeOption, setSkippedWallTimeOption, setTime, setTimeInMillis, setTimeZone, setWeekData, toString, validateField, validateFields, weekNumber, weekNumber
-
-
-
-
Field Detail
-
TISHRI
public static final int TISHRI
Constant for Tishri, the 1st month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
HESHVAN
public static final int HESHVAN
Constant for Heshvan, the 2nd month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
KISLEV
public static final int KISLEV
Constant for Kislev, the 3rd month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
TEVET
public static final int TEVET
Constant for Tevet, the 4th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
SHEVAT
public static final int SHEVAT
Constant for Shevat, the 5th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
ADAR_1
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).- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
ADAR
public static final int ADAR
Constant for the Adar, the 7th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
NISAN
public static final int NISAN
Constant for Nisan, the 8th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
IYAR
public static final int IYAR
Constant for Iyar, the 9th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
SIVAN
public static final int SIVAN
Constant for Sivan, the 10th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
TAMUZ
public static final int TAMUZ
Constant for Tammuz, the 11th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
AV
public static final int AV
Constant for Av, the 12th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
ELUL
public static final int ELUL
Constant for Elul, the 13th month of the Hebrew year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 2.8.
-
-
Constructor Detail
-
HebrewCalendar
public HebrewCalendar()
Constructs a defaultHebrewCalendarusing the current time in the default time zone with the defaultFORMATlocale.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 2.8.
-
HebrewCalendar
public HebrewCalendar(TimeZone zone)
Constructs aHebrewCalendarbased on the current time in the given time zone with the defaultFORMATlocale.- Parameters:
zone- The time zone for the new calendar.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 2.8.
-
HebrewCalendar
public HebrewCalendar(Locale aLocale)
Constructs aHebrewCalendarbased on the current time in the default time zone with the given locale.- Parameters:
aLocale- The locale for the new calendar.- Status:
- Stable ICU 2.8.
-
HebrewCalendar
public HebrewCalendar(ULocale locale)
Constructs aHebrewCalendarbased on the current time in the default time zone with the given locale.- Parameters:
locale- The locale for the new calendar.- Status:
- Stable ICU 3.2.
-
HebrewCalendar
public HebrewCalendar(TimeZone zone, Locale aLocale)
Constructs aHebrewCalendarbased on the current time in the given time zone with the given locale.- Parameters:
zone- The time zone for the new calendar.aLocale- The locale for the new calendar.- Status:
- Stable ICU 2.8.
-
HebrewCalendar
public HebrewCalendar(TimeZone zone, ULocale locale)
Constructs aHebrewCalendarbased on the current time in the given time zone with the given locale.- Parameters:
zone- The time zone for the new calendar.locale- The locale for the new calendar.- Status:
- Stable ICU 3.2.
-
HebrewCalendar
public HebrewCalendar(int year, int month, int date)Constructs aHebrewCalendarwith the given date set in the default time zone with the defaultFORMATlocale.- Parameters:
year- The value used to set the calendar'sYEARtime field.month- The value used to set the calendar'sMONTHtime field. The value is 0-based. e.g., 0 for Tishri.date- The value used to set the calendar'sDATEtime field.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 2.8.
-
HebrewCalendar
public HebrewCalendar(Date date)
Constructs aHebrewCalendarwith the given date set in the default time zone with the defaultFORMATlocale.- Parameters:
date- The date to which the new calendar is set.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 2.8.
-
HebrewCalendar
public HebrewCalendar(int year, int month, int date, int hour, int minute, int second)Constructs aHebrewCalendarwith the given date and time set for the default time zone with the defaultFORMATlocale.- Parameters:
year- The value used to set the calendar'sYEARtime field.month- The value used to set the calendar'sMONTHtime field. The value is 0-based. e.g., 0 for Tishri.date- The value used to set the calendar'sDATEtime field.hour- The value used to set the calendar'sHOUR_OF_DAYtime field.minute- The value used to set the calendar'sMINUTEtime field.second- The value used to set the calendar'sSECONDtime field.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 2.8.
-
-
Method Detail
-
add
public void add(int field, int amount)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 calladd(Calendar.DATE, 3).When adding to certain fields, the values of other fields may conflict and need to be changed. For example, when adding one to the
MONTHfield for the date "30 Av 5758", theDAY_OF_MONTHfield must be adjusted so that the result is "29 Elul 5758" rather than the invalid "30 Elul 5758".This method is able to add to all fields except for
ERA,DST_OFFSET, andZONE_OFFSET.Note: You should always use
rolland add rather than attempting to perform arithmetic operations directly on the fields of aHebrewCalendar. Since theMONTHfield behaves discontinuously in non-leap years, simple arithmetic can give invalid results.- Overrides:
addin classCalendar- Parameters:
field- the time field.amount- the amount to add to the field.- Throws:
IllegalArgumentException- if the field is invalid or refers to a field that cannot be handled by this method.- See Also:
Calendar.roll(int, int)- Status:
- Stable ICU 2.8.
-
roll
public void roll(int field, int amount)Rolls (up/down) a specified amount time on the given field. For example, to roll the current date up by three days, you can callroll(Calendar.DATE, 3). If the field is rolled past its maximum allowable value, it will "wrap" back to its minimum and continue rolling. For example, callingroll(Calendar.DATE, 10)on a Hebrew calendar set to "25 Av 5758" will result in the date "5 Av 5758".When rolling certain fields, the values of other fields may conflict and need to be changed. For example, when rolling the
MONTHfield upward by one for the date "30 Av 5758", theDAY_OF_MONTHfield must be adjusted so that the result is "29 Elul 5758" rather than the invalid "30 Elul".This method is able to roll all fields except for
ERA,DST_OFFSET, andZONE_OFFSET. Subclasses may, of course, add support for additional fields in their overrides ofroll.Note: You should always use roll and
addrather than attempting to perform arithmetic operations directly on the fields of aHebrewCalendar. Since theMONTHfield behaves discontinuously in non-leap years, simple arithmetic can give invalid results.- Overrides:
rollin classCalendar- Parameters:
field- the time field.amount- the amount by which the field should be rolled.- Throws:
IllegalArgumentException- if the field is invalid or refers to a field that cannot be handled by this method.- See Also:
Calendar.roll(int, boolean),Calendar.add(int, int)- Status:
- Stable ICU 2.8.
-
isLeapYear
@Deprecated 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.- Status:
- Internal. This API is ICU internal only.
-
handleGetLimit
protected int handleGetLimit(int field, int limitType)Description copied from class:CalendarSubclass 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
- Specified by:
handleGetLimitin classCalendar- Parameters:
field- one of the above field numberslimitType- one ofMINIMUM,GREATEST_MINIMUM,LEAST_MAXIMUM, orMAXIMUM- Status:
- Stable ICU 2.8.
-
handleGetMonthLength
protected int handleGetMonthLength(int extendedYear, int month)Returns the length of the given month in the given year- Overrides:
handleGetMonthLengthin classCalendar- Status:
- Stable ICU 2.8.
-
handleGetYearLength
protected int handleGetYearLength(int eyear)
Returns the number of days in the given Hebrew year- Overrides:
handleGetYearLengthin classCalendar- Status:
- Stable ICU 2.8.
-
validateField
@Deprecated protected void validateField(int field)
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 byCalendar.validateField().Overrides
Calendar.validateField(int)to provide special handling for month validation for Hebrew calendar.- Overrides:
validateFieldin classCalendar- See Also:
Calendar.validateField(int, int, int)- Status:
- Internal. This API is ICU internal only.
-
handleComputeFields
protected void handleComputeFields(int julianDay)
Subclasses may override this method to compute several fields specific to each calendar system. These are:- ERA
- YEAR
- MONTH
- DAY_OF_MONTH
- DAY_OF_YEAR
- EXTENDED_YEAR
In addition, subclasses should compute any subclass-specific fields, that is, fields from BASE_FIELD_COUNT to getFieldCount() - 1.
- Overrides:
handleComputeFieldsin classCalendar- Status:
- Stable ICU 2.8.
-
handleGetExtendedYear
protected int handleGetExtendedYear()
Description copied from class:CalendarReturns 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.- Specified by:
handleGetExtendedYearin classCalendar- Returns:
- the extended year
- Status:
- Stable ICU 2.8.
-
handleComputeMonthStart
protected int handleComputeMonthStart(int eyear, int month, boolean useMonth)Return JD of start of given month/year.- Specified by:
handleComputeMonthStartin classCalendar- Parameters:
eyear- the extended yearmonth- the zero-based month, or 0 if useMonth is falseuseMonth- 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- Returns:
- the Julian day number of the day before the first day of the given month and year
- Status:
- Stable ICU 2.8.
-
getType
public String getType()
[icu] Returns the calendar type name string for this Calendar object. The returned string is the legacy ICU calendar attribute value, for example, "gregorian" or "japanese".See type="old type name" for the calendar attribute of locale IDs at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
-
getRelatedYearDifference
@Deprecated protected final int getRelatedYearDifference()
Deprecated.This API is ICU internal only.- Overrides:
getRelatedYearDifferencein classCalendar- Status:
- Internal. This API is ICU internal only.
-
inTemporalLeapYear
public boolean inTemporalLeapYear()
[icu] Returns true if the date is in a leap year. Recalculate the current time field values if the time value has been changed by a call to * setTime(). This method is semantically const, but may alter the object in memory. A "leap year" is a year that contains more days than other years (for solar or lunar calendars) or more months than other years (for lunisolar calendars like Hebrew or Chinese), as defined in the ECMAScript Temporal proposal.- Overrides:
inTemporalLeapYearin classCalendar- Returns:
- true if the date in the fields is in a Temporal proposal defined leap year. False otherwise.
- Status:
- Stable ICU 74.
-
getTemporalMonthCode
public String getTemporalMonthCode()
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.- Overrides:
getTemporalMonthCodein classCalendar- Returns:
- One of 13 possible strings in {"M01".. "M05", "M05L", "M06" .. "M12"}.
- Status:
- Stable ICU 74.
-
setTemporalMonthCode
public void setTemporalMonthCode(String 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. For Hebrew calendar, the values are "M01" .. "M12" for non-leap years, and "M01" .. "M05", "M05L", "M06" .. "M12" for leap year.- Overrides:
setTemporalMonthCodein classCalendar- Parameters:
temporalMonth- The value to be set for temporal monthCode.- Status:
- Stable ICU 74.
-
internalGetMonth
@Deprecated protected int internalGetMonth()
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.- Overrides:
internalGetMonthin classCalendar- Returns:
- the value for the given time field.
- Status:
- Internal. This API is ICU internal only.
-
-