public
class
HebrewCalendar
extends Calendar
java.lang.Object | ||
↳ | android.icu.util.Calendar | |
↳ | android.icu.util.HebrewCalendar |
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
getInstance(ULocale)
passing in a ULocale
with the tag "@calendar=hebrew"
.
See also:
Constants | |
---|---|
int |
ADAR
Constant for the Adar, the 7th month of the Hebrew year. |
int |
ADAR_1
Constant for Adar I, the 6th month of the Hebrew year (present in leap years only). |
int |
AV
Constant for Av, the 12th month of the Hebrew year. |
int |
ELUL
Constant for Elul, the 13th month of the Hebrew year. |
int |
HESHVAN
Constant for Heshvan, the 2nd month of the Hebrew year. |
int |
IYAR
Constant for Iyar, the 9th month of the Hebrew year. |
int |
KISLEV
Constant for Kislev, the 3rd month of the Hebrew year. |
int |
NISAN
Constant for Nisan, the 8th month of the Hebrew year. |
int |
SHEVAT
Constant for Shevat, the 5th month of the Hebrew year. |
int |
SIVAN
Constant for Sivan, the 10th month of the Hebrew year. |
int |
TAMUZ
Constant for Tammuz, the 11th month of the Hebrew year. |
int |
TEVET
Constant for Tevet, the 4th month of the Hebrew year. |
int |
TISHRI
Constant for Tishri, the 1st month of the Hebrew year. |
Inherited constants |
---|
From
class
android.icu.util.Calendar
|
Inherited fields |
---|
From
class
android.icu.util.Calendar
|
Public constructors | |
---|---|
HebrewCalendar()
Constructs a default |
|
HebrewCalendar(TimeZone zone)
Constructs a |
|
HebrewCalendar(Locale aLocale)
Constructs a |
|
HebrewCalendar(ULocale locale)
Constructs a |
|
HebrewCalendar(TimeZone zone, Locale aLocale)
Constructs a |
|
HebrewCalendar(TimeZone zone, ULocale locale)
Constructs a |
|
HebrewCalendar(int year, int month, int date)
Constructs a |
|
HebrewCalendar(Date date)
Constructs a |
|
HebrewCalendar(int year, int month, int date, int hour, int minute, int second)
Constructs a |
Public methods | |
---|---|
void
|
add(int field, int amount)
Add a signed amount to a specified field, using this calendar's rules. |
String
|
getType()
[icu] Returns the calendar type name string for this Calendar object. |
void
|
roll(int field, int amount)
Rolls (up/down) a specified amount time on the given field. |
Protected methods | |
---|---|
void
|
handleComputeFields(int julianDay)
Subclasses may override this method to compute several fields specific to each calendar system. |
int
|
handleComputeMonthStart(int eyear, int month, boolean useMonth)
Return JD of start of given month/year. |
int
|
handleGetExtendedYear()
Returns the extended year defined by the current fields. |
int
|
handleGetLimit(int field, int limitType)
Subclass API for defining limits of different types. |
int
|
handleGetMonthLength(int extendedYear, int month)
Returns the length of the given month in the given year |
int
|
handleGetYearLength(int eyear)
Returns the number of days in the given Hebrew year |
Inherited methods | |
---|---|
From
class
android.icu.util.Calendar
| |
From
class
java.lang.Object
| |
From
interface
java.lang.Comparable
|
int ADAR
Constant for the Adar, the 7th month of the Hebrew year.
Constant Value: 6 (0x00000006)
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).
Constant Value: 5 (0x00000005)
int AV
Constant for Av, the 12th month of the Hebrew year.
Constant Value: 11 (0x0000000b)
int ELUL
Constant for Elul, the 13th month of the Hebrew year.
Constant Value: 12 (0x0000000c)
int HESHVAN
Constant for Heshvan, the 2nd month of the Hebrew year.
Constant Value: 1 (0x00000001)
int IYAR
Constant for Iyar, the 9th month of the Hebrew year.
Constant Value: 8 (0x00000008)
int KISLEV
Constant for Kislev, the 3rd month of the Hebrew year.
Constant Value: 2 (0x00000002)
int NISAN
Constant for Nisan, the 8th month of the Hebrew year.
Constant Value: 7 (0x00000007)
int SHEVAT
Constant for Shevat, the 5th month of the Hebrew year.
Constant Value: 4 (0x00000004)
int SIVAN
Constant for Sivan, the 10th month of the Hebrew year.
Constant Value: 9 (0x00000009)
int TAMUZ
Constant for Tammuz, the 11th month of the Hebrew year.
Constant Value: 10 (0x0000000a)
int TEVET
Constant for Tevet, the 4th month of the Hebrew year.
Constant Value: 3 (0x00000003)
int TISHRI
Constant for Tishri, the 1st month of the Hebrew year.
Constant Value: 0 (0x00000000)
HebrewCalendar ()
Constructs a default HebrewCalendar
using the current time
in the default time zone with the default FORMAT
locale.
See also:
HebrewCalendar (TimeZone zone)
Constructs a HebrewCalendar
based on the current time
in the given time zone with the default FORMAT
locale.
Parameters | |
---|---|
zone |
TimeZone :
The time zone for the new calendar. |
See also:
HebrewCalendar (Locale aLocale)
Constructs a HebrewCalendar
based on the current time
in the default time zone with the given locale.
Parameters | |
---|---|
aLocale |
Locale :
The locale for the new calendar.
|
HebrewCalendar (ULocale locale)
Constructs a HebrewCalendar
based on the current time
in the default time zone with the given locale.
Parameters | |
---|---|
locale |
ULocale :
The locale for the new calendar.
|
HebrewCalendar (TimeZone zone, Locale aLocale)
Constructs a HebrewCalendar
based on the current time
in the given time zone with the given locale.
Parameters | |
---|---|
zone |
TimeZone :
The time zone for the new calendar. |
aLocale |
Locale :
The locale for the new calendar.
|
HebrewCalendar (TimeZone zone, ULocale locale)
Constructs a HebrewCalendar
based on the current time
in the given time zone with the given locale.
Parameters | |
---|---|
zone |
TimeZone :
The time zone for the new calendar. |
locale |
ULocale :
The locale for the new calendar.
|
HebrewCalendar (int year, int month, int date)
Constructs a HebrewCalendar
with the given date set
in the default time zone with the default FORMAT
locale.
Parameters | |
---|---|
year |
int :
The value used to set the calendar's YEAR time field. |
month |
int :
The value used to set the calendar's MONTH time field.
The value is 0-based. e.g., 0 for Tishri. |
date |
int :
The value used to set the calendar's DATE time field. |
See also:
HebrewCalendar (Date date)
Constructs a HebrewCalendar
with the given date set
in the default time zone with the default FORMAT
locale.
Parameters | |
---|---|
date |
Date :
The date to which the new calendar is set. |
See also:
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 FORMAT
locale.
Parameters | |
---|---|
year |
int :
The value used to set the calendar's YEAR time field. |
month |
int :
The value used to set the calendar's MONTH time field.
The value is 0-based. e.g., 0 for Tishri. |
date |
int :
The value used to set the calendar's DATE time field. |
hour |
int :
The value used to set the calendar's HOUR_OF_DAY time field. |
minute |
int :
The value used to set the calendar's MINUTE time field. |
second |
int :
The value used to set the calendar's SECOND time field. |
See also:
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 MONTH
field
for the date "30 Av 5758", the 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 ERA
, DST_OFFSET
,
and ZONE_OFFSET
.
Note: You should always use roll
and add rather
than attempting to perform arithmetic operations directly on the fields
of a HebrewCalendar. Since the MONTH
field behaves
discontinuously in non-leap years, simple arithmetic can give invalid results.
Parameters | |
---|---|
field |
int :
the time field. |
amount |
int :
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. |
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
Returns | |
---|---|
String |
legacy calendar type name string |
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 MONTH
field
upward by one for the date "30 Av 5758", the 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 ERA
, DST_OFFSET
,
and ZONE_OFFSET
. Subclasses may, of course, add support for
additional fields in their overrides of roll
.
Note: You should always use roll and add
rather
than attempting to perform arithmetic operations directly on the fields
of a HebrewCalendar. Since the MONTH
field behaves
discontinuously in non-leap years, simple arithmetic can give invalid results.
Parameters | |
---|---|
field |
int :
the time field. |
amount |
int :
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. |
void handleComputeFields (int julianDay)
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.
Parameters | |
---|---|
julianDay |
int
|
int handleComputeMonthStart (int eyear, int month, boolean useMonth)
Return JD of start of given month/year.
Parameters | |
---|---|
eyear |
int :
the extended year |
month |
int :
the zero-based month, or 0 if useMonth is false |
useMonth |
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 |
Returns | |
---|---|
int |
the Julian day number of the day before the first day of the given month and year |
int handleGetExtendedYear ()
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.
Returns | |
---|---|
int |
the extended year |
int handleGetLimit (int field, int limitType)
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
Parameters | |
---|---|
field |
int :
one of the above field numbers |
limitType |
int :
one of MINIMUM , GREATEST_MINIMUM ,
LEAST_MAXIMUM , or MAXIMUM
|
Returns | |
---|---|
int |
int handleGetMonthLength (int extendedYear, int month)
Returns the length of the given month in the given year
Parameters | |
---|---|
extendedYear |
int
|
month |
int
|
Returns | |
---|---|
int |
int handleGetYearLength (int eyear)
Returns the number of days in the given Hebrew year
Parameters | |
---|---|
eyear |
int
|
Returns | |
---|---|
int |