HebrewCalendar
open class HebrewCalendar : Calendar
kotlin.Any | ||
↳ | 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:
- "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 android.icu.util.Calendar#getInstance(ULocale)
passing in a ULocale
with the tag "@calendar=hebrew"
.
Summary
Constants | |
---|---|
static Int |
Constant for the Adar, the 7th month of the Hebrew year. |
static Int |
Constant for Adar I, the 6th month of the Hebrew year (present in leap years only). |
static Int |
Constant for Av, the 12th month of the Hebrew year. |
static Int |
Constant for Elul, the 13th month of the Hebrew year. |
static Int |
Constant for Heshvan, the 2nd month of the Hebrew year. |
static Int |
Constant for Iyar, the 9th month of the Hebrew year. |
static Int |
Constant for Kislev, the 3rd month of the Hebrew year. |
static Int |
Constant for Nisan, the 8th month of the Hebrew year. |
static Int |
Constant for Shevat, the 5th month of the Hebrew year. |
static Int |
Constant for Sivan, the 10th month of the Hebrew year. |
static Int |
Constant for Tammuz, the 11th month of the Hebrew year. |
static Int |
Constant for Tevet, the 4th month of the Hebrew year. |
static Int |
Constant for Tishri, the 1st month of the Hebrew year. |
Inherited constants | |
---|---|
Public constructors | |
---|---|
Constructs a default |
|
HebrewCalendar(zone: TimeZone!) Constructs a |
|
HebrewCalendar(zone: TimeZone!, locale: ULocale!) Constructs a |
|
HebrewCalendar(zone: TimeZone!, aLocale: Locale!) Constructs a |
|
HebrewCalendar(locale: ULocale!) Constructs a |
|
HebrewCalendar(year: Int, month: Int, date: Int) Constructs a |
|
Constructs a |
|
HebrewCalendar(date: Date!) Constructs a |
|
HebrewCalendar(aLocale: Locale!) Constructs a |
Public methods | |
---|---|
open Unit |
Add a signed amount to a specified field, using this calendar's rules. |
open String! |
Gets The Temporal monthCode value corresponding to the month for the date. |
open String! |
getType() [icu] Returns the calendar type name string for this Calendar object. |
open Boolean |
[icu] Returns true if the date is in a leap year. |
open Unit |
Rolls (up/down) a specified amount time on the given field. |
open Unit |
setTemporalMonthCode(temporalMonth: String!) 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 methods | |
---|---|
open Unit |
handleComputeFields(julianDay: Int) Subclasses may override this method to compute several fields specific to each calendar system. |
open Int |
handleComputeMonthStart(eyear: Int, month: Int, useMonth: Boolean) Return JD of start of given month/year. |
open Int | |
open Int |
handleGetLimit(field: Int, limitType: Int) |
open Int |
handleGetMonthLength(extendedYear: Int, month: Int) Returns the length of the given month in the given year |
open Int |
handleGetYearLength(eyear: Int) Returns the number of days in the given Hebrew year |
Inherited functions | |
---|---|
Inherited properties | |
---|---|
Constants
ADAR
static val ADAR: Int
Constant for the Adar, the 7th month of the Hebrew year.
Value: 6
ADAR_1
static val ADAR_1: Int
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).
Value: 5
AV
static val AV: Int
Constant for Av, the 12th month of the Hebrew year.
Value: 11
ELUL
static val ELUL: Int
Constant for Elul, the 13th month of the Hebrew year.
Value: 12
HESHVAN
static val HESHVAN: Int
Constant for Heshvan, the 2nd month of the Hebrew year.
Value: 1
IYAR
static val IYAR: Int
Constant for Iyar, the 9th month of the Hebrew year.
Value: 8
KISLEV
static val KISLEV: Int
Constant for Kislev, the 3rd month of the Hebrew year.
Value: 2
NISAN
static val NISAN: Int
Constant for Nisan, the 8th month of the Hebrew year.
Value: 7
SHEVAT
static val SHEVAT: Int
Constant for Shevat, the 5th month of the Hebrew year.
Value: 4
SIVAN
static val SIVAN: Int
Constant for Sivan, the 10th month of the Hebrew year.
Value: 9
TAMUZ
static val TAMUZ: Int
Constant for Tammuz, the 11th month of the Hebrew year.
Value: 10
TEVET
static val TEVET: Int
Constant for Tevet, the 4th month of the Hebrew year.
Value: 3
TISHRI
static val TISHRI: Int
Constant for Tishri, the 1st month of the Hebrew year.
Value: 0
Public constructors
HebrewCalendar
HebrewCalendar()
Constructs a default HebrewCalendar
using the current time in the default time zone with the default FORMAT
locale.
HebrewCalendar
HebrewCalendar(zone: TimeZone!)
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. |
HebrewCalendar
HebrewCalendar(
zone: TimeZone!,
locale: ULocale!)
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
HebrewCalendar(
zone: TimeZone!,
aLocale: 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. |
aLocale |
Locale!: The locale for the new calendar. |
HebrewCalendar
HebrewCalendar(locale: ULocale!)
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
HebrewCalendar(
year: Int,
month: Int,
date: Int)
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. |
HebrewCalendar
HebrewCalendar(
year: Int,
month: Int,
date: Int,
hour: Int,
minute: Int,
second: Int)
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. |
HebrewCalendar
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. |
HebrewCalendar
HebrewCalendar(aLocale: Locale!)
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. |
Public methods
add
open fun add(
field: Int,
amount: Int
): Unit
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. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the field is invalid or refers to a field that cannot be handled by this method. |
getTemporalMonthCode
open fun getTemporalMonthCode(): String!
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.
Return | |
---|---|
String! |
One of 13 possible strings in {"M01".. "M05", "M05L", "M06" .. "M12"}. |
getType
open fun getType(): String!
[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
Return | |
---|---|
String! |
legacy calendar type name string |
inTemporalLeapYear
open fun inTemporalLeapYear(): Boolean
[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.
Return | |
---|---|
Boolean |
true if the date in the fields is in a Temporal proposal defined leap year. False otherwise. |
roll
open fun roll(
field: Int,
amount: Int
): Unit
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. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the field is invalid or refers to a field that cannot be handled by this method. |
setTemporalMonthCode
open fun setTemporalMonthCode(temporalMonth: String!): Unit
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.
Parameters | |
---|---|
temporalMonth |
String!: The value to be set for temporal monthCode. |
Protected methods
handleComputeFields
protected open fun handleComputeFields(julianDay: Int): Unit
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.
handleComputeMonthStart
protected open fun handleComputeMonthStart(
eyear: Int,
month: Int,
useMonth: Boolean
): Int
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 |
Return | |
---|---|
Int |
the Julian day number of the day before the first day of the given month and year |
handleGetExtendedYear
protected open fun handleGetExtendedYear(): Int
Return | |
---|---|
Int |
the extended year |
handleGetLimit
protected open fun handleGetLimit(
field: Int,
limitType: Int
): Int
Parameters | |
---|---|
field |
Int: one of the above field numbers |
limitType |
Int: one of MINIMUM , GREATEST_MINIMUM , LEAST_MAXIMUM , or MAXIMUM |
handleGetMonthLength
protected open fun handleGetMonthLength(
extendedYear: Int,
month: Int
): Int
Returns the length of the given month in the given year
handleGetYearLength
protected open fun handleGetYearLength(eyear: Int): Int
Returns the number of days in the given Hebrew year