com.ibm.icu.util

Class HebrewCalendar

public class HebrewCalendar extends Calendar

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 {@link #roll roll} and {@link #add 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 {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a ULocale with the tag "@calendar=hebrew".

Author: Laura Werner Alan Liu

See Also: GregorianCalendar

UNKNOWN: ICU 2.8

Field Summary
static intADAR
Constant for the Adar, the 7th month of the Hebrew year.
static intADAR_1
Constant for Adar I, the 6th month of the Hebrew year (present in leap years only).
static intAV
Constant for Av, the 12th month of the Hebrew year.
static intELUL
Constant for Elul, the 13th month of the Hebrew year.
static intHESHVAN
Constant for Heshvan, the 2nd month of the Hebrew year.
static intIYAR
Constant for Iyar, the 9th month of the Hebrew year.
static intKISLEV
Constant for Kislev, the 3rd month of the Hebrew year.
static intNISAN
Constant for Nisan, the 8th month of the Hebrew year.
static intSHEVAT
Constant for Shevat, the 5th month of the Hebrew year.
static intSIVAN
Constant for Sivan, the 10th month of the Hebrew year.
static intTAMUZ
Constant for Tammuz, the 11th month of the Hebrew year.
static intTEVET
Constant for Tevet, the 4th month of the Hebrew year.
static intTISHRI
Constant for Tishri, the 1st month of the Hebrew year.
Constructor Summary
HebrewCalendar()
Constructs a default HebrewCalendar using the current time in the default time zone with the default locale.
HebrewCalendar(TimeZone zone)
Constructs a HebrewCalendar based on the current time in the given time zone with the default locale.
HebrewCalendar(Locale aLocale)
Constructs a HebrewCalendar based on the current time in the default time zone with the given locale.
HebrewCalendar(ULocale locale)
Constructs a HebrewCalendar based on the current time in the default time zone with the given locale.
HebrewCalendar(TimeZone zone, Locale aLocale)
Constructs a HebrewCalendar based on the current time in the given time zone with the given locale.
HebrewCalendar(TimeZone zone, ULocale locale)
Constructs a HebrewCalendar based on the current time in the given time zone with the given locale.
HebrewCalendar(int year, int month, int date)
Constructs a HebrewCalendar with the given date set in the default time zone with the default locale.
HebrewCalendar(Date date)
Constructs a HebrewCalendar with the given date set in the default time zone with the default locale.
HebrewCalendar(int year, int month, int date, int hour, int minute, int second)
Constructs a HebrewCalendar with the given date and time set for the default time zone with the default locale.
Method Summary
voidadd(int field, int amount)
Add a signed amount to a specified field, using this calendar's rules.
StringgetType()
Return the current Calendar type.
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()
protected inthandleGetLimit(int field, int limitType)
protected inthandleGetMonthLength(int extendedYear, int month)
Returns the length of the given month in the given year
protected inthandleGetYearLength(int eyear)
Returns the number of days in the given Hebrew year
voidroll(int field, int amount)
Rolls (up/down) a specified amount time on the given field.

Field Detail

ADAR

public static final int ADAR
Constant for the Adar, the 7th month of the Hebrew year.

UNKNOWN: 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).

UNKNOWN: ICU 2.8

AV

public static final int AV
Constant for Av, the 12th month of the Hebrew year.

UNKNOWN: ICU 2.8

ELUL

public static final int ELUL
Constant for Elul, the 13th month of the Hebrew year.

UNKNOWN: ICU 2.8

HESHVAN

public static final int HESHVAN
Constant for Heshvan, the 2nd month of the Hebrew year.

UNKNOWN: ICU 2.8

IYAR

public static final int IYAR
Constant for Iyar, the 9th month of the Hebrew year.

UNKNOWN: ICU 2.8

KISLEV

public static final int KISLEV
Constant for Kislev, the 3rd month of the Hebrew year.

UNKNOWN: ICU 2.8

NISAN

public static final int NISAN
Constant for Nisan, the 8th month of the Hebrew year.

UNKNOWN: ICU 2.8

SHEVAT

public static final int SHEVAT
Constant for Shevat, the 5th month of the Hebrew year.

UNKNOWN: ICU 2.8

SIVAN

public static final int SIVAN
Constant for Sivan, the 10th month of the Hebrew year.

UNKNOWN: ICU 2.8

TAMUZ

public static final int TAMUZ
Constant for Tammuz, the 11th month of the Hebrew year.

UNKNOWN: ICU 2.8

TEVET

public static final int TEVET
Constant for Tevet, the 4th month of the Hebrew year.

UNKNOWN: ICU 2.8

TISHRI

public static final int TISHRI
Constant for Tishri, the 1st month of the Hebrew year.

UNKNOWN: ICU 2.8

Constructor Detail

HebrewCalendar

public HebrewCalendar()
Constructs a default HebrewCalendar using the current time in the default time zone with the default locale.

UNKNOWN: ICU 2.8

HebrewCalendar

public HebrewCalendar(TimeZone zone)
Constructs a HebrewCalendar based on the current time in the given time zone with the default locale.

Parameters: zone The time zone for the new calendar.

UNKNOWN: ICU 2.8

HebrewCalendar

public HebrewCalendar(Locale aLocale)
Constructs a HebrewCalendar based on the current time in the default time zone with the given locale.

Parameters: aLocale The locale for the new calendar.

UNKNOWN: ICU 2.8

HebrewCalendar

public HebrewCalendar(ULocale locale)
Constructs a HebrewCalendar based on the current time in the default time zone with the given locale.

Parameters: locale The locale for the new calendar.

UNKNOWN: ICU 3.2 This API might change or be removed in a future release.

HebrewCalendar

public HebrewCalendar(TimeZone zone, Locale aLocale)
Constructs a HebrewCalendar based 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.

UNKNOWN: ICU 2.8

HebrewCalendar

public HebrewCalendar(TimeZone zone, ULocale locale)
Constructs a HebrewCalendar based 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.

UNKNOWN: ICU 3.2 This API might change or be removed in a future release.

HebrewCalendar

public HebrewCalendar(int year, int month, int date)
Constructs a HebrewCalendar with the given date set in the default time zone with the default locale.

Parameters: year The value used to set the calendar's {@link #YEAR YEAR} time field. month The value used to set the calendar's {@link #MONTH MONTH} time field. The value is 0-based. e.g., 0 for Tishri. date The value used to set the calendar's {@link #DATE DATE} time field.

UNKNOWN: ICU 2.8

HebrewCalendar

public HebrewCalendar(Date date)
Constructs a HebrewCalendar with the given date set in the default time zone with the default locale.

Parameters: date The date to which the new calendar is set.

UNKNOWN: ICU 2.8

HebrewCalendar

public HebrewCalendar(int year, int month, int date, int hour, int minute, int second)
Constructs a HebrewCalendar with the given date and time set for the default time zone with the default locale.

Parameters: year The value used to set the calendar's {@link #YEAR YEAR} time field. month The value used to set the calendar's {@link #MONTH MONTH} time field. The value is 0-based. e.g., 0 for Tishri. date The value used to set the calendar's {@link #DATE DATE} time field. hour The value used to set the calendar's {@link #HOUR_OF_DAY HOUR_OF_DAY} time field. minute The value used to set the calendar's {@link #MINUTE MINUTE} time field. second The value used to set the calendar's {@link #SECOND SECOND} time field.

UNKNOWN: 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 call add(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 {@link #MONTH MONTH} field for the date "30 Av 5758", the {@link #DAY_OF_MONTH DAY_OF_MONTH} field 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 {@link #ERA ERA}, {@link #DST_OFFSET DST_OFFSET}, and {@link #ZONE_OFFSET ZONE_OFFSET}.

Note: You should always use {@link #roll roll} and add rather than attempting to perform arithmetic operations directly on the fields of a HebrewCalendar. Since the {@link #MONTH MONTH} field behaves discontinuously in non-leap years, simple arithmetic can give invalid results.

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.

UNKNOWN: ICU 2.8

getType

public String getType()
Return the current Calendar type.

Returns: type of calendar (gregorian, etc.)

UNKNOWN: ICU 3.0

handleComputeFields

protected void handleComputeFields(int julianDay)
Subclasses may override this method to compute several fields specific to each calendar system. These are: Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which will be set when this method is called. Subclasses can also call the getGregorianXxx() methods to obtain Gregorian calendar equivalents for the given Julian day.

In addition, subclasses should compute any subclass-specific fields, that is, fields from BASE_FIELD_COUNT to getFieldCount() - 1.

UNKNOWN: ICU 2.8

handleComputeMonthStart

protected int handleComputeMonthStart(int eyear, int month, boolean useMonth)
Return JD of start of given month/year.

UNKNOWN: ICU 2.8

handleGetExtendedYear

protected int handleGetExtendedYear()

UNKNOWN: ICU 2.8

handleGetLimit

protected int handleGetLimit(int field, int limitType)

UNKNOWN: ICU 2.8

handleGetMonthLength

protected int handleGetMonthLength(int extendedYear, int month)
Returns the length of the given month in the given year

UNKNOWN: ICU 2.8

handleGetYearLength

protected int handleGetYearLength(int eyear)
Returns the number of days in the given Hebrew year

UNKNOWN: 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 call roll(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, calling roll(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 {@link #MONTH MONTH} field upward by one for the date "30 Av 5758", the {@link #DAY_OF_MONTH DAY_OF_MONTH} field 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 {@link #ERA ERA}, {@link #DST_OFFSET DST_OFFSET}, and {@link #ZONE_OFFSET ZONE_OFFSET}. Subclasses may, of course, add support for additional fields in their overrides of roll.

Note: You should always use roll and {@link #add add} rather than attempting to perform arithmetic operations directly on the fields of a HebrewCalendar. Since the {@link #MONTH MONTH} field behaves discontinuously in non-leap years, simple arithmetic can give invalid results.

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.

UNKNOWN: ICU 2.8

Copyright (c) 2006 IBM Corporation and others.