Class HebrewCalendar
- All Implemented Interfaces:
Serializable
,Comparable<HebrewCalendar>
,CalendarDate
,ChronoDisplay
,Temporal<CalendarDate>
,LocalizedPatternSupport
Represents the calendar used by the worldwide Jewish community, but mainly in Israel for religious purposes.
Introduction
It is a lunisolar calendar which defines years consisting of 12 or 13 months. The month cycle generally follows the lunar cycle of synodic moon. However, every two or three years, an extra leap month called ADAR-I will be inserted to synchronize the calendar with the solar year. This is done by help of the metonic cycle. This synchronization is not perfect because the mean length of the hebrew year of 365.2468 days is slightly longer than the tropical solar year. See also Wikipedia. The implementation of this calendar is based on the book "Calendrical calculations" of Dershowitz/Reingold. The hebrew day starts at sunset on the previous day. By default and as rough approximation, the time 18:00 o'clock is used - especially in case of missing geographic location. However, Time4J enables users to use the exact astronomical sunset as begin of day for religious purposes.
Following elements which are declared as constants are registered by this class
Furthermore, all elements defined in EpochDays
and CommonElements
are supported.
Formatting of the month Adar-II
The month Adar-II is printed in different ways dependent on if the associated year is a leap year or not.
HebrewCalendar date = HebrewCalendar.of(5778, HebrewMonth.ADAR_II, 29); ChronoFormatter<HebrewCalendar> f = ChronoFormatter.ofPattern( "MMMM, dd (yyyy)", PatternType.CLDR_DATE, Locale.US, HebrewCalendar.axis()); assertThat(f.format(date), is("Adar, 29 (5778)")); // no leap year assertThat(f.format(date.plus(1, HebrewCalendar.Unit.YEARS)), is("Adar II, 29 (5779)"));
Support for unicode ca-extensions
Locale locale = Locale.forLanguageTag("en-u-ca-hebrew"); ChronoFormatter<CalendarDate> f = ChronoFormatter.ofGenericCalendarStyle(DisplayMode.FULL, locale); assertThat( f.format(PlainDate.of(2017, 10, 1)), is("Sunday, Tishri 11, 5778 AM"));
- Since:
- 3.37/4.32
- Author:
- Meno Hochschild
- See Also:
HebrewAnniversary
,HebrewMonth
,HebrewTime
, Serialized Form
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Defines some calendar units for the Hebrew calendar. -
Field Summary
Modifier and TypeFieldDescriptionstatic StdCalendarElement<Integer,HebrewCalendar>
Equivalent toCommonElements.boundedWeekOfMonth(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.static StdCalendarElement<Integer,HebrewCalendar>
Equivalent toCommonElements.boundedWeekOfYear(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.static StdCalendarElement<Integer,HebrewCalendar>
Represents the Hebrew day of month.static StdCalendarElement<Weekday,HebrewCalendar>
Represents the Hebrew day of week.static StdCalendarElement<Integer,HebrewCalendar>
Represents the Hebrew day of year.static ChronoElement<HebrewEra>
Represents the Hebrew era.static StdCalendarElement<Weekday,HebrewCalendar>
Equivalent toCommonElements.localDayOfWeek(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.static StdCalendarElement<HebrewMonth,HebrewCalendar>
Represents the Hebrew month.static StdCalendarElement<Integer,HebrewCalendar>
Equivalent toCommonElements.weekOfMonth(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.static StdCalendarElement<Integer,HebrewCalendar>
Equivalent toCommonElements.weekOfYear(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.static OrdinalWeekdayElement<HebrewCalendar>
Element with the ordinal day-of-week within given calendar month.static StdCalendarElement<Integer,HebrewCalendar>
Represents the Hebrew year. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new local timestamp with this date and given civil time.atTime(int hour, int minute)
Is equivalent toat(PlainTime.of(hour, minute))
.static TimeAxis<HebrewCalendar.Unit,HebrewCalendar>
axis()
Returns the associated time axis.Interpretes this date as birth date of a boy and determines the 13th birthday.Interpretes this date as birth date of a girl and determines the 12th birthday.boolean
Based on the epoch day number and the calendar system.int
Yields the Hebrew day of month.Determines the day of week.int
Yields the Hebrew day of year.static Weekmodel
Obtains the standard week model of this calendar.getEra()
Yields the Hebrew era.getMonth()
Yields the Hebrew month.int
getYear()
Yields the Hebrew year.int
hashCode()
Based on the epoch day number.boolean
Is the year of this date a leap year which has 13 instead of 12 months?static boolean
isLeapYear(int year)
Is the given hebrew year a leap year which has 13 instead of 12 months?boolean
Is the year of this date Rosh Chodesh?boolean
Is the year of this date a sabbatical year as described in the bible?static boolean
isValid(int yearOfEra, HebrewMonth month, int dayOfMonth)
Queries if given parameter values form a well defined calendar date.int
Yields the length of current Hebrew month in days.int
Yields the length of current Hebrew year in days.static HebrewCalendar
Obtains the current calendar date in system time.static HebrewCalendar
nowInSystemTime(StartOfDay startOfDay)
Obtains the current calendar date in system time with given start of day.static HebrewCalendar
of(int year, HebrewMonth month, int dom)
Creates a new instance of a Hebrew calendar date.static HebrewCalendar
ofBiblical(int year, int month, int dom)
Creates a new instance of a Hebrew calendar date.static HebrewCalendar
ofCivil(int year, int month, int dom)
Creates a new instance of a Hebrew calendar date.toString()
Provides a complete textual representation of the state of this time point.Methods inherited from class net.time4j.engine.Calendrical
compareTo, getDaysSinceEpochUTC, isAfter, isBefore, isSimultaneous, minus, plus
Methods inherited from class net.time4j.engine.TimePoint
max, min, minus, minus, plus, plus, until, until
Methods inherited from class net.time4j.engine.ChronoEntity
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, with
Methods inherited from interface net.time4j.engine.CalendarDate
transform, transform, transform, transform, transform, transform
Methods inherited from interface net.time4j.format.LocalizedPatternSupport
getFormatPattern, getFormatPattern, useDynamicFormatPattern
Methods inherited from interface net.time4j.engine.Temporal
isAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual
-
Field Details
-
ERA
Represents the Hebrew era.
-
YEAR_OF_ERA
@FormattableElement(format="y") public static final StdCalendarElement<Integer,HebrewCalendar> YEAR_OF_ERARepresents the Hebrew year.
-
MONTH_OF_YEAR
@FormattableElement(format="M", alt="L") public static final StdCalendarElement<HebrewMonth,HebrewCalendar> MONTH_OF_YEARRepresents the Hebrew month.
-
DAY_OF_MONTH
@FormattableElement(format="d") public static final StdCalendarElement<Integer,HebrewCalendar> DAY_OF_MONTHRepresents the Hebrew day of month.
-
DAY_OF_YEAR
@FormattableElement(format="D") public static final StdCalendarElement<Integer,HebrewCalendar> DAY_OF_YEARRepresents the Hebrew day of year.
-
DAY_OF_WEEK
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,HebrewCalendar> DAY_OF_WEEKRepresents the Hebrew day of week.
If the day-of-week is set to a new value then Time4J handles the Hebrew calendar week as starting on Sunday (more precisely on Saturday evening).
-
WEEKDAY_IN_MONTH
@FormattableElement(format="F") public static final OrdinalWeekdayElement<HebrewCalendar> WEEKDAY_IN_MONTHElement with the ordinal day-of-week within given calendar month.
-
LOCAL_DAY_OF_WEEK
Equivalent to
CommonElements.localDayOfWeek(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.- Since:
- 3.41/4.36
- See Also:
CommonElements.localDayOfWeek(Chronology, Weekmodel)
,getDefaultWeekmodel()
-
WEEK_OF_YEAR
Equivalent to
CommonElements.weekOfYear(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.- Since:
- 3.41/4.36
- See Also:
CommonElements.weekOfYear(Chronology, Weekmodel)
,getDefaultWeekmodel()
-
WEEK_OF_MONTH
Equivalent to
CommonElements.weekOfMonth(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.- Since:
- 3.41/4.36
- See Also:
CommonElements.weekOfMonth(Chronology, Weekmodel)
,getDefaultWeekmodel()
-
BOUNDED_WEEK_OF_YEAR
Equivalent to
CommonElements.boundedWeekOfYear(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.- Since:
- 3.41/4.36
- See Also:
CommonElements.boundedWeekOfYear(Chronology, Weekmodel)
,getDefaultWeekmodel()
-
BOUNDED_WEEK_OF_MONTH
Equivalent to
CommonElements.boundedWeekOfMonth(HebrewCalendar.axis(), HebrewCalendar.getDefaultWeekmodel())
.- Since:
- 3.41/4.36
- See Also:
CommonElements.boundedWeekOfMonth(Chronology, Weekmodel)
,getDefaultWeekmodel()
-
-
Method Details
-
of
Creates a new instance of a Hebrew calendar date.
- Parameters:
year
- Hebrew year in the range 1-9999month
- Hebrew monthdom
- Hebrew day of month in range 1-30- Returns:
- new instance of
HebrewCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies
-
ofCivil
Creates a new instance of a Hebrew calendar date.
- Parameters:
year
- Hebrew year in the range 1-9999month
- Hebrew civil month in the range 1-13dom
- Hebrew day of month in range 1-30- Returns:
- new instance of
HebrewCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies- See Also:
HebrewMonth.getCivilValue(boolean)
-
ofBiblical
Creates a new instance of a Hebrew calendar date.
- Parameters:
year
- Hebrew year in the range 1-9999month
- Hebrew biblical month in the range 1-13dom
- Hebrew day of month in range 1-30- Returns:
- new instance of
HebrewCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies- See Also:
HebrewMonth.getBiblicalValue(boolean)
-
nowInSystemTime
Obtains the current calendar date in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(HebrewCalendar.axis())
. Attention: The Hebrew calendar changes here the date in the evening at 6 PM (on previous day). If users wish more control over the start of day then following code might be used:SolarTime jerusalem = SolarTime.ofLocation(31.779167, 35.223611); HebrewCalendar currentHebrewDate = HebrewCalendar.nowInSystemTime(StartOfDay.definedBy(jerusalem.sunset()));
- Returns:
- current calendar date in system time zone using the system clock
- See Also:
SystemClock.inLocalView()
,ZonalClock.now(Chronology)
,StartOfDay.definedBy(ChronoFunction)
,SolarTime.sunset()
-
nowInSystemTime
Obtains the current calendar date in system time with given start of day.
- Parameters:
startOfDay
- exact definition when the day starts (should be sunset on previous day)- Returns:
- current calendar date in system time zone using the system clock
- Since:
- 5.5
- See Also:
StartOfDay.definedBy(ChronoFunction)
,SolarTime.sunset()
-
getEra
Yields the Hebrew era.
- Returns:
HebrewEra.ANNO_MUNDI
-
getYear
public int getYear()Yields the Hebrew year.
- Returns:
- int
-
getMonth
Yields the Hebrew month.
- Returns:
- enum
-
getDayOfMonth
public int getDayOfMonth()Yields the Hebrew day of month.
- Returns:
- int
-
getDayOfWeek
Determines the day of week.
The Hebrew calendar also uses a 7-day-week.
- Returns:
- Weekday
-
getDayOfYear
public int getDayOfYear()Yields the Hebrew day of year.
- Returns:
- int
-
lengthOfMonth
public int lengthOfMonth()Yields the length of current Hebrew month in days.
- Returns:
- int
-
lengthOfYear
public int lengthOfYear()Yields the length of current Hebrew year in days.
- Returns:
- int
-
isLeapYear
public static boolean isLeapYear(int year)Is the given hebrew year a leap year which has 13 instead of 12 months?
The years 3, 6, 8, 11, 14, 17 and 19 in the 19 year Metonic cycle are leap years.
- Parameters:
year
- the hebrew year- Returns:
- boolean
- Throws:
IllegalArgumentException
- if the year is not positive
-
isLeapYear
public boolean isLeapYear()Is the year of this date a leap year which has 13 instead of 12 months?
- Returns:
- boolean
- See Also:
isLeapYear(int)
-
isSabbaticalYear
public boolean isSabbaticalYear()Is the year of this date a sabbatical year as described in the bible?
Every seventh year is a sabbatical year, see Exodus 23:10-11.
- Returns:
- boolean
-
isRoshChodesh
public boolean isRoshChodesh()Is the year of this date Rosh Chodesh?
This term describes the head of the month where the day-of-month is 1 unless it is the month Tishri. If the previous month has 30 days then the 30th of the previous month is also associated with the Rosh Chodesh. Note that Tishri 1 is Rosh Hashana (head of the year).
- Returns:
- boolean
-
isValid
Queries if given parameter values form a well defined calendar date.
- Parameters:
yearOfEra
- the year of era to be checkedmonth
- the month to be checkeddayOfMonth
- the day of month to be checked- Returns:
true
if valid elsefalse
- See Also:
of(int, HebrewMonth, int)
-
barMitzvah
Interpretes this date as birth date of a boy and determines the 13th birthday.
- Returns:
- date of bar mitzvah
- See Also:
HebrewAnniversary.BIRTHDAY
-
batMitzvah
Interpretes this date as birth date of a girl and determines the 12th birthday.
- Returns:
- date of bat mitzvah
- See Also:
HebrewAnniversary.BIRTHDAY
-
at
Creates a new local timestamp with this date and given civil time.
If the time
T24:00
is used then the resulting timestamp will automatically be normalized such that the timestamp will contain the following day instead.An alternative to the civil time is the usage of the
HebrewTime
according to the descriptions in the bible and torah.- Parameters:
time
- wall time- Returns:
- general timestamp as composition of this date and given time
- See Also:
HebrewTime.on(HebrewCalendar, SolarTime)
,HebrewTime.on(HebrewCalendar, Timezone)
-
atTime
Is equivalent to
at(PlainTime.of(hour, minute))
.- Parameters:
hour
- hour of day in range (0-24)minute
- minute of hour in range (0-59)- Returns:
- general timestamp as composition of this date and given time
- Throws:
IllegalArgumentException
- if any argument is out of range- See Also:
at(PlainTime)
,HebrewTime.on(HebrewCalendar, SolarTime)
,HebrewTime.on(HebrewCalendar, Timezone)
-
equals
Description copied from class:Calendrical
Based on the epoch day number and the calendar system.
In other words: Two date object are equal if they have the same temporal position on the local timeline and have the same calendrical type. Subclasses which define further state attributes must override this method.
If an only temporal comparison is required then the method
Calendrical.isSimultaneous(CalendarDate)
is to be used.- Overrides:
equals
in classCalendrical<HebrewCalendar.Unit,HebrewCalendar>
- See Also:
Chronology.getChronoType()
-
hashCode
public int hashCode()Description copied from class:Calendrical
Based on the epoch day number.
- Overrides:
hashCode
in classCalendrical<HebrewCalendar.Unit,HebrewCalendar>
-
toString
Description copied from class:TimePoint
Provides a complete textual representation of the state of this time point.
The textual description often follows the conventions of ISO-8601. Usually the description starts with the chronological informations which are coarse-grained and ends with those ones which are fine-grained (for example the ISO-notation YYYY-MM-DD).
- Specified by:
toString
in classTimePoint<HebrewCalendar.Unit,HebrewCalendar>
-
getDefaultWeekmodel
Obtains the standard week model of this calendar.
The Hebrew calendar usually starts on Sunday (more precisely on Saturday evening). Friday and Saturday are considered as weekend (as usual in Israel).
- Returns:
- Weekmodel
-
axis
Returns the associated time axis.
- Returns:
- chronology
-