Class JewishDate
java.lang.Object
com.kosherjava.zmanim.hebrewcalendar.JewishDate
- All Implemented Interfaces:
Cloneable, Comparable<JewishDate>
- Direct Known Subclasses:
JewishCalendar
The JewishDate is the base calendar class, that supports maintenance of a
LocalDate
instance along with the corresponding Jewish date. This class can use the standard Java Date and Calendar
classes for setting and maintaining the dates, but it does not subclass these classes or use them internally
in any calculations. This class also does not have a concept of a time (which the Date class does). Please
note that the calendar does not currently support dates prior to 1/1/1 Gregorian. Also keep in mind that the
Gregorian calendar started on October 15, 1582, so any calculations prior to that are suspect (at least from
a Gregorian perspective). While 1/1/1 Gregorian and forward are technically supported, any calculations prior to Hillel II's (Hakatan's) calendar (4119 in the Jewish Calendar / 359
CE Julian as recorded by Rav Hai Gaon) would be just an
approximation.
This open source Java code was written by Avrom Finkelstien from his C++
code. It was refactored to fit the KosherJava Zmanim API with simplification of the code, enhancements and some bug
fixing.
Some of Avrom's original C++ code was translated from
C/C++ code in
Calendrical Calculations by Nachum Dershowitz and Edward M.
Reingold, Software-- Practice & Experience, vol. 20, no. 9 (September, 1990), pp. 899- 928. Any method with the mark
"ND+ER" indicates that the method was taken from this source with minor modifications.
If you are looking for a class that implements a Jewish calendar version of the Calendar class, one is available from
the ICU (International Components for Unicode) project, formerly part of
IBM's DeveloperWorks.- Author:
- © Avrom Finkelstien 2002, © Moshe Dicker 2026, © Eliyahu Hershfeld 2011 - 2026
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intValue of the month field indicating Adar (or Adar I in aleap year), the twelfth numeric month of the year in the Jewish calendar.static final intValue of the month field indicating Adar II, the leap (intercalary or embolismic) thirteenth (Undecimber) numeric month of the year added in Jewishleap year).static final intValue of the month field indicating Av, the fifth numeric month of the year in the Jewish calendar.private static final intDays from the beginning of Sunday till molad BaHaRaD.private static final longThe number of chalakim (25,920) in a 24-hour day .private static final intThe number of chalakim (1080) in an hour.private static final intThe number of chalakim (18) in a minute.private static final longThe number of chalakim in an average Jewish month.static final intstatic final intValue of the month field indicating Cheshvan/marcheshvan, the eighth numeric month of the year in the Jewish calendar.private int1 == Sunday, 2 == Monday, etc...static final intValue of the month field indicating Elul, the sixth numeric month of the year in the Jewish calendar.private intReturns the absolute date (days since January 1, 0001 of the Gregorian calendar).static final intValue of the month field indicating Iyar, the second numeric month of the year in the Jewish calendar.private static final intthe Jewish epoch using the RD (Rata Die/Fixed Date or Reingold Dershowitz) day used in Calendrical Calculations.private intthe internal Jewish day.private intthe internal Jewish month.private intthe internal Jewish year.static final intstatic final intValue of the month field indicating Kislev, the ninth numeric month of the year in the Jewish calendar.private intthe internal count of molad chalakim.private intthe internal count of molad hours.private intthe internal count of molad minutes.static final intValue of the month field indicating Nissan, the first numeric month of the year in the Jewish calendar.static final intstatic final intValue of the month field indicating Shevat, the eleventh numeric month of the year in the Jewish calendar.static final intValue of the month field indicating Sivan, the third numeric month of the year in the Jewish calendar.static final intValue of the month field indicating Tammuz, the fourth numeric month of the year in the Jewish calendar.static final intValue of the month field indicating Teves, the tenth numeric month of the year in the Jewish calendar.static final intValue of the month field indicating Tishrei, the seventh numeric month of the year in the Jewish calendar. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor will set a default date to the current system date.JewishDate(int jewishYear, int jewishMonth, int jewishDayOfMonth) Creates a Jewish date based on a Jewish year, month and day of month.JewishDate(long molad) Constructor that creates a JewishDate based on a molad passed in.JewishDate(LocalDate localDate) A constructor that initializes the date to theLocalDateparameter.JewishDate(ZonedDateTime zonedDateTime) A constructor that initializes the date to theZonedDateTimeparameter. -
Method Summary
Modifier and TypeMethodDescriptionprivate static LocalDateabsDateToDate(int absDate) Computes the Gregorian date from the absolute date.private static intaddDechiyos(int year, int moladDay, int moladParts) Adds the 4 dechiyos for molad Tishrei.clone()A method that creates a deep copy of the object.intcompareTo(JewishDate jewishDate) Compares two dates as per the compareTo() method in the Comparable interface.booleanIndicates whether some other object is "equal to" this one.intReturns the absolute date (days since January 1, 0001 of the Gregorian calendar).longReturns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu to the Jewish year and month that this Object is set to.private static longgetChalakimSinceMoladTohu(int year, int month) Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu to the year and month passed in.intReturns the Cheshvan and Kislev kviah (whether a Jewish year is short, regular or long).intReturns the day of the week as a number between 1-7.intReturns the number of days of the Jewish month that the calendar is currently set to.private static intgetDaysInJewishMonth(int year, int month) Returns the number of days of a Jewish month for a given month and year.intReturns the number of days for the current year that the calendar is set to.static intgetDaysInJewishYear(int year) Returns the number of days for a given Jewish year.intreturns the number of days from Rosh Hashana of the date passed in, to the full date passed in.private static intgetDaysSinceStartOfJewishYear(int year, int month, int dayOfMonth) returns the number of days from Rosh Hashana of the date passed in, to the full date passed in.static intgetJewishCalendarElapsedDays(int year) Returns the number of days elapsed from the Sunday prior to the start of the Jewish calendar to the mean conjunction of Tishri of the Jewish year.intReturns the Jewish day of month.intReturns the Jewish month 1-12 (or 13 years in a leap year).private static intgetJewishMonthOfYear(int year, int month) intReturns the Jewish year.private static intgetLastDayOfGregorianMonth(int year, int month) Returns the number of days in a given month in a given year and month.private static intgetLastMonthOfJewishYear(int year) Returns the last month of a given Jewish year.Returns this object's date as aLocalDateobject.getMolad()Returns the molad for a given year and month.intReturns the molad chalakim / parts.intReturns the molad hours.intReturns the molad minutes.private static intgregorianDateToAbsDate(int year, int month, int dayOfMonth) Computes the absolute date from a Gregorian date.inthashCode()OverridesObject.hashCode().booleanReturns if Cheshvan is long (30 days VS 29 days) for the current year that the calendar is set to.private static booleanisCheshvanLong(int year) Returns if Cheshvan is long in a given Jewish year.booleanReturns if the year the calendar is set to is a Jewish leap year.static booleanisJewishLeapYear(int year) Returns if the year is a Jewish leap year.booleanReturns if the Kislev is short for the year that this class is set to.private static booleanisKislevShort(int year) Returns if Kislev is short (29 days VS 30 days) in a given Jewish year.private static intjewishDateToAbsDate(int year, int month, int dayOfMonth) Returns the absolute date of Jewish date.voidminusDays(int days) Subtracts the number of days passed in from the currently set date.voidminusMonths(int months) Subtracts the number of months passed in to the currently set date.voidminusYears(int years, boolean useAdarAlephForLeapYear) Subtract the number of years passed in to the currently set date.private static intmoladToAbsDate(long chalakim) Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in.voidplusDays(int days) Add the number of days passed in to the currently set date.voidplusMonths(int months) Add the number of months passed in to the currently set date.voidplusYears(int years, boolean useAdarAlephForLeapYear) Add the number of years passed in to the currently set date.voidResets this date to the current system date.private voidsetAbsDate(int gregorianAbsDate) Computes and sets the Jewish date fields based on the provided absolute (Gregorian) date.voidsetGregorianDate(LocalDate localDate) Sets the date based on aLocalDateobject.voidsetGregorianDate(ZonedDateTime zonedDateTime) Sets the date based on aZonedDateTimeobject.voidsetJewishDate(int year, int month, int dayOfMonth) Sets the Jewish Date and updates the Gregorian date accordingly.voidsetJewishDate(int year, int month, int dayOfMonth, int hours, int minutes, int chalakim) Sets the Jewish Date and updates the Gregorian date accordingly.voidsetJewishDayOfMonth(int dayOfMonth) Setter for the Jewish day of the month that will be clamped to the lesser of the number passed in or the max number of days in the month.voidsetJewishMonth(int month) Setter for the Jewish month that is passed in.voidsetJewishYear(int year) Setter for the Jewish year of the passed in that will clamp the day to the month to the lesser of the current day and the max number of days in the month (if set to the 30th).voidsetMoladChalakim(int moladChalakim) Sets the molad chalakim/parts.voidsetMoladHours(int moladHours) Sets the molad hours.voidsetMoladMinutes(int moladMinutes) Sets the molad minutes.toString()Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729".private static voidvalidateJewishDate(int year, int month, int dayOfMonth, int hours, int minutes, int chalakim) Validates the components of a Jewish date for validity.
-
Field Details
-
NISSAN
-
IYAR
-
SIVAN
-
TAMMUZ
-
AV
-
ELUL
-
TISHREI
Value of the month field indicating Tishrei, the seventh numeric month of the year in the Jewish calendar. With the year starting at this month, it would actually be the 1st month of the year.- See Also:
-
CHESHVAN
-
KISLEV
-
TEVES
-
SHEVAT
-
ADAR
-
ADAR_II
Value of the month field indicating Adar II, the leap (intercalary or embolismic) thirteenth (Undecimber) numeric month of the year added in Jewishleap year). The leap years are years 3, 6, 8, 11, 14, 17 and 19 of a 19-year cycle. With the year starting atTISHREI, it would actually be the 7th month of the year.- See Also:
-
JEWISH_EPOCH
the Jewish epoch using the RD (Rata Die/Fixed Date or Reingold Dershowitz) day used in Calendrical Calculations. Day 1 is January 1, 0001 of the Gregorian calendar- See Also:
-
CHALAKIM_PER_MINUTE
-
CHALAKIM_PER_HOUR
-
CHALAKIM_PER_DAY
The number of chalakim (25,920) in a 24-hour day .- See Also:
-
CHALAKIM_PER_MONTH
The number of chalakim in an average Jewish month. A month has 29 days, 12 hours and 793 chalakim (44 minutes and 3.3 seconds) for a total of 765,433 chalakim- See Also:
-
CHALAKIM_MOLAD_TOHU
Days from the beginning of Sunday till molad BaHaRaD. Calculated as 1 day, 5 hours and 204 chalakim = (24 + 5) * 1080 + 204 = 31524- See Also:
-
CHASERIM
-
KESIDRAN
-
SHELAIMIM
-
jewishMonth
the internal Jewish month. -
jewishDay
the internal Jewish day. -
jewishYear
the internal Jewish year. -
moladHours
the internal count of molad hours. -
moladMinutes
the internal count of molad minutes. -
moladChalakim
the internal count of molad chalakim. -
dayOfWeek
1 == Sunday, 2 == Monday, etc... -
gregorianAbsDate
Returns the absolute date (days since January 1, 0001 of the Gregorian calendar).- See Also:
-
-
Constructor Details
-
JewishDate
Constructor that creates a JewishDate based on a molad passed in. The molad would be the number of chalakim / parts starting at the beginning of Sunday prior to the Molad Tohu BeHaRaD (Be = Monday, Ha = 5 hours and RaD = 204 chalakim / parts) - prior to the start of the Jewish calendar. BeHaRaD is 23:11:20 on Sunday night(5 hours 204/1080 chalakim after sunset on Sunday evening).- Parameters:
molad- the number of chalakim since the beginning of Sunday prior to BaHaRaD
-
JewishDate
Creates a Jewish date based on a Jewish year, month and day of month.- Parameters:
jewishYear- the Jewish yearjewishMonth- the Jewish month. The method expects a 1 for Nissan ... 12 for Adar and 13 for Adar II. Use the constantsNISSAN...ADAR(orADAR_IIfor a leap year Adar II) to avoid any confusion.jewishDayOfMonth- the Jewish day of month. If 30 is passed in for a month with only 29 days (for exampleIYAR, orKISLEVin a year thatisKislevShort()), the 29th (last valid date of the month) will be set.- Throws:
IllegalArgumentException- if the day of month is < 1 or > 30, or a year of < 0 is passed in.
-
JewishDate
public JewishDate()Default constructor will set a default date to the current system date. -
JewishDate
A constructor that initializes the date to theZonedDateTimeparameter.- Parameters:
zonedDateTime- theZonedDateTimeto set the calendar to
-
JewishDate
A constructor that initializes the date to theLocalDateparameter.- Parameters:
localDate- theLocalDateto set the calendar to
-
-
Method Details
-
getMoladHours
Returns the molad hours. Only a JewishDate object populated withgetMolad(),setJewishDate(int, int, int, int, int, int)orsetMoladHours(int)will have this field populated. A regular JewishDate object will have this field set to 0.- Returns:
- the molad hours
- See Also:
-
setMoladHours
Sets the molad hours.- Parameters:
moladHours- the molad hours to set- See Also:
-
getMoladMinutes
Returns the molad minutes. Only an object populated withgetMolad(),setJewishDate(int, int, int, int, int, int)or orsetMoladMinutes(int)will have these fields populated. A regular JewishDate object will have this field set to 0.- Returns:
- the molad minutes
- See Also:
-
setMoladMinutes
Sets the molad minutes. The expectation is that the traditional minute-less chalakim will be broken out to minutes andchalakim / parts, so 793 (TaShTZaG) parts would have the minutes set to 44 and chalakim to 1.- Parameters:
moladMinutes- the molad minutes to set- See Also:
-
setMoladChalakim
Sets the molad chalakim/parts. The expectation is that the traditional minute-less chalakim will be broken out tominutesand chalakim, so 793 (TaShTZaG) parts would have the minutes set to 44 and chalakim to 1.- Parameters:
moladChalakim- the molad chalakim / parts to set- See Also:
-
getMoladChalakim
Returns the molad chalakim / parts. Only an object populated withgetMolad(),setJewishDate(int, int, int, int, int, int)or orsetMoladChalakim(int)will have these fields populated. A regular JewishDate object will have this field set to 0.- Returns:
- the molad chalakim / parts
- See Also:
-
getLastDayOfGregorianMonth
Returns the number of days in a given month in a given year and month.- Parameters:
year- the year (only impacts February)month- the month. As with other cases in this class, this is 1-based, not zero-based.- Returns:
- the number of days in the month in the given year
-
absDateToDate
Computes the Gregorian date from the absolute date. ND+ER- Parameters:
absDate- the absolute date- Returns:
- the
LocalDate.
-
getAbsDate
Returns the absolute date (days since January 1, 0001 of the Gregorian calendar).- Returns:
- the number of days since January 1, 1
-
gregorianDateToAbsDate
Computes the absolute date from a Gregorian date. ND+ER- Parameters:
year- the Gregorian yearmonth- the Gregorian month. Unlike the Java Calendar where January has the value of 0,This expects a 1 for JanuarydayOfMonth- the day of the month (1st, 2nd, etc...)- Returns:
- the absolute Gregorian day
-
isJewishLeapYear
Returns if the year is a Jewish leap year. Years 3, 6, 8, 11, 14, 17 and 19 in the 19-year cycle are leap years.- Parameters:
year- the Jewish year.- Returns:
- true if it is a leap year
- See Also:
-
isJewishLeapYear
Returns if the year the calendar is set to is a Jewish leap year. Years 3, 6, 8, 11, 14, 17 and 19 in the 19-year cycle are leap years.- Returns:
- true if it is a leap year
- See Also:
-
getLastMonthOfJewishYear
Returns the last month of a given Jewish year. This will be 12 on a nonleap yearor 13 on a leap year.- Parameters:
year- the Jewish year.- Returns:
- 12 on a non leap year or 13 on a leap year
- See Also:
-
getJewishCalendarElapsedDays
Returns the number of days elapsed from the Sunday prior to the start of the Jewish calendar to the mean conjunction of Tishri of the Jewish year.- Parameters:
year- the Jewish year- Returns:
- the number of days elapsed from prior to the molad Tohu BaHaRaD (Be = Monday, Ha = 5 hours and RaD = 204 chalakim / parts) prior to the start of the Jewish calendar, to the mean conjunction of Tishri of the Jewish year. BeHaRaD is 23:11:20 on Sunday night(5 hours 204/1080 chalakim after sunset on Sunday evening).
-
addDechiyos
Adds the 4 dechiyos for molad Tishrei. These are:- Lo ADU Rosh - Rosh Hashana can't fall on a Sunday, Wednesday or Friday. If the molad fell on one of these days, Rosh Hashana is delayed to the following day.
- Molad Zaken - If the molad of Tishrei falls after 12 noon, Rosh Hashana is delayed to the following day. If the following day is ADU, it will be delayed an additional day.
- GaTRaD - If on a non leap year the molad of Tishrei falls on a Tuesday (Ga) on or after 9 hours (T) and (RaD 204 chalakim it is delayed till Thursday (one day delay, plus one day for Lo ADU Rosh)
- BeTuTaKPaT - if the year following a leap year falls on a Monday (Be) on or after 15 hours (Tu) and 589 chalakim (TaKPaT) it is delayed till Tuesday
- Parameters:
year- the yearmoladDay- the molad daymoladParts- the molad parts- Returns:
- the number of elapsed days in the JewishCalendar adjusted for the 4 dechiyos.
-
getChalakimSinceMoladTohu
Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu to the year and month passed in.- Parameters:
year- the Jewish yearmonth- the Jewish month the Jewish month, with the month numbers starting from Nissan. Use the JewishDate constants such asTISHREI.- Returns:
- the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu
-
getChalakimSinceMoladTohu
Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu to the Jewish year and month that this Object is set to.- Returns:
- the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu
-
getJewishMonthOfYear
-
validateJewishDate
private static void validateJewishDate(int year, int month, int dayOfMonth, int hours, int minutes, int chalakim) Validates the components of a Jewish date for validity. It will throw anIllegalArgumentExceptionif the Jewish date is earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on aleap year), the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 or > 59 or chalakim < 0 or > 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 / TaShTzaG).- Parameters:
year- the Jewish year to validate. It will reject any year <= 3761 (lower than the year 1 Gregorian).month- the Jewish month to validate. It will reject a month < 1 or > 12 (or 13 on a leap year) .dayOfMonth- the day of the Jewish month to validate. It will reject any value < 1 or > 30 TODO: check calling methods to see if there is any reason that the class can validate that 30 is invalid for some months.hours- the hours (for molad calculations). It will reject an hour < 0 or > 23minutes- the minutes (for molad calculations). It will reject a minute < 0 or > 59chalakim- the chalakim / parts (for molad calculations). It will reject a chalakim < 0 or > 17. For larger numbers such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 / TaShTzaG)- Throws:
IllegalArgumentException- if a Jewish date earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a leap year), the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 or > 59 or chalakim < 0 or > 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 (TaShTzaG).
-
getDaysInJewishYear
Returns the number of days for a given Jewish year. ND+ER- Parameters:
year- the Jewish year- Returns:
- the number of days for a given Jewish year.
- See Also:
-
getDaysInJewishYear
Returns the number of days for the current year that the calendar is set to.- Returns:
- the number of days for the Object's current Jewish year.
- See Also:
-
isCheshvanLong
Returns if Cheshvan is long in a given Jewish year. The method name isLong is done since in a Kesidran (ordered) year Cheshvan is short. ND+ER- Parameters:
year- the year- Returns:
- true if Cheshvan is long in Jewish year.
- See Also:
-
isCheshvanLong
Returns if Cheshvan is long (30 days VS 29 days) for the current year that the calendar is set to. The method name isLong is done since in a Kesidran (ordered) year Cheshvan is short.- Returns:
- true if Cheshvan is long for the current year that the calendar is set to
- See Also:
-
isKislevShort
Returns if Kislev is short (29 days VS 30 days) in a given Jewish year. The method name isShort is done since in a Kesidran (ordered) year Kislev is long. ND+ER- Parameters:
year- the Jewish year- Returns:
- true if Kislev is short for the given Jewish year.
- See Also:
-
isKislevShort
Returns if the Kislev is short for the year that this class is set to. The method name isShort is done since in a Kesidran (ordered) year Kislev is long.- Returns:
- true if Kislev is short for the year that this class is set to
-
getCheshvanKislevKviah
-
getDaysInJewishMonth
Returns the number of days of a Jewish month for a given month and year.- Parameters:
year- the Jewish Yearmonth- the Jewish month- Returns:
- the number of days for a given Jewish month
-
getDaysInJewishMonth
Returns the number of days of the Jewish month that the calendar is currently set to.- Returns:
- the number of days for the Jewish month that the calendar is currently set to.
-
setAbsDate
Computes and sets the Jewish date fields based on the provided absolute (Gregorian) date.- Parameters:
gregorianAbsDate- the Gregorian absolute date.
-
jewishDateToAbsDate
Returns the absolute date of Jewish date. ND+ER- Parameters:
year- the Jewish year. The year can't be negativemonth- the Jewish month starting with Nissan. Nissan expects a value of 1 etc. until Adar with a value of 12. For a leap year, 13 will be the expected value for Adar II. Use the constantsNISSANetc.dayOfMonth- the Jewish day of month. valid values are 1-30. If the day of month is set to 30 for a month that only has 29 days, the day will be set as 29.- Returns:
- the absolute date of the Jewish date.
-
getMolad
Returns the molad for a given year and month. Returns a JewishDateObjectset to the date of the molad with thehours,minutesandchalakimset. In the current implementation, it sets the molad time based on a midnight date rollover. This means that Rosh Chodesh Adar II, 5771 with a molad of 7 chalakim past midnight on Shabbos 29 Adar I / March 5, 2011 12:00 AM and 7 chalakim, will have the following values: hours: 0, minutes: 0, Chalakim: 7. -
moladToAbsDate
Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in.- Parameters:
chalakim- the number of chalakim since the beginning of Sunday prior to BaHaRaD- Returns:
- the number of days from the Jewish epoch
-
getDaysSinceStartOfJewishYear
returns the number of days from Rosh Hashana of the date passed in, to the full date passed in.- Parameters:
year- the Jewish yearmonth- the Jewish monthdayOfMonth- the day in the Jewish month- Returns:
- the number of days
-
getDaysSinceStartOfJewishYear
returns the number of days from Rosh Hashana of the date passed in, to the full date passed in.- Returns:
- the number of days
-
setGregorianDate
Sets the date based on aZonedDateTimeobject. Modifies the Jewish date as well.- Parameters:
zonedDateTime- theZonedDateTimeto set the calendar to
-
setGregorianDate
Sets the date based on aLocalDateobject. Modifies the Jewish date as well.- Parameters:
localDate- theLocalDateto set the calendar to- Throws:
IllegalArgumentException- if the date would fall prior to the year 1 AD
-
setJewishDate
Sets the Jewish Date and updates the Gregorian date accordingly.- Parameters:
year- the Jewish year. The year can't be negativemonth- the Jewish month starting with Nissan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for Adar II. Use the constantsNISSAN...ADAR(orADAR_IIfor a leap year Adar II) to avoid any confusion.dayOfMonth- the Jewish day of month. valid values are 1-30. If the day of month is set to 30 for a month that only has 29 days, the day will be set as 29.- Throws:
IllegalArgumentException- if a Jewish date earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a leap year) or the day of month is < 1 or > 30 is passed in
-
setJewishDate
public void setJewishDate(int year, int month, int dayOfMonth, int hours, int minutes, int chalakim) Sets the Jewish Date and updates the Gregorian date accordingly.- Parameters:
year- the Jewish year. The year can't be negativemonth- the Jewish month starting with Nissan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for Adar II. Use the constantsNISSAN...ADAR(orADAR_IIfor a leap year Adar II) to avoid any confusion.dayOfMonth- the Jewish day of month. valid values are 1-30. If the day of month is set to 30 for a month that only has 29 days, the day will be set as 29.hours- the hour of the day. Used for molad calculationsminutes- the minutes. Used for molad calculationschalakim- the chalakim / parts. Used for molad calculations. The chalakim should not exceed 17. Minutes should be used for larger numbers.- Throws:
IllegalArgumentException- if a Jewish date earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a leap year), the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 > 59 or chalakim < 0 > 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 (TaShTzaG).
-
setJewishDayOfMonth
Setter for the Jewish day of the month that will be clamped to the lesser of the number passed in or the max number of days in the month.- Parameters:
dayOfMonth- the day of the month to set the date to.
-
setJewishMonth
Setter for the Jewish month that is passed in. If the day of month is currently the 30th and the month is being set to a month that only has 29 days, the day of month will be clamped to the 29th of the month.- Parameters:
month- the month to be set
-
setJewishYear
Setter for the Jewish year of the passed in that will clamp the day to the month to the lesser of the current day and the max number of days in the month (if set to the 30th). Note that if you are using this for a yahrzeit (or any other reason)on the 30th of the month that will not always have 30 days, such asCHESHVANorKISLEVorADAR Ion a leap year and the next year is a non-leap year, you must clone your date or once it is set to the 29th, the next time you forward it to a year that has 30 days, the calendar will incorrectly be forwarded a year from the 29th to the 29th and not the 30th that you may expect.- Parameters:
year- the year to set.
-
getLocalDate
-
resetDate
Resets this date to the current system date. -
minusDays
Subtracts the number of days passed in from the currently set date.- Parameters:
days- the number of days to subtract.- See Also:
-
plusDays
Add the number of days passed in to the currently set date.- Parameters:
days- the number of days to add.- See Also:
-
plusMonths
Add the number of months passed in to the currently set date. If the day of the month prior to addition is the 30th, and the target month only has 29 days, the date will be clamped to the 29th.- Parameters:
months- the number of months to add.- See Also:
-
minusMonths
Subtracts the number of months passed in to the currently set date. If the day of the month prior to subtraction is the 30th, and the target month only has 29 days, the date will be clamped to the 29th.- Parameters:
months- the number of months to subtract.- See Also:
-
plusYears
Add the number of years passed in to the currently set date. If the current month is Adar on a non-leap year, and the year after the addition will be a leap year, passingtrueto the useAdarAlephForLeapYear parameter will set the month to Adar I, and passingfalsewill forward it to Adar II. The useAdarAlephForLeapYear will be ignored if the month is not Adar. If the current year is a leap year and it is currently Adar I or Adar II and the year it is being increased to is also a leap year, the same Adar will be used. If it is being increased to a non-leap year, the month will be set to Adar. It is important to keep in mind when calculating yahrzits that are on the 30th and the target year only has 29 days, that the date will be set to the 29th, something that may nt be desirable.- Parameters:
years- the number of years to adduseAdarAlephForLeapYear- if set to true and the current month is Adar on a non-leap year and it is being moved forward to a leap year, it will be set to Adar I, and if set to false it will set to Adar II. This will be ignored if the month is not set to Adar.- See Also:
-
minusYears
Subtract the number of years passed in to the currently set date. If the current month is Adar on a non-leap year, and the year after the subtraction will be a leap year, passingtrueto the useAdarAlephForLeapYear parameter will set the month to Adar I, and passingfalsewill set it to Adar II. The useAdarAlephForLeapYear will be ignored if the current month is not Adar on a non-leap year. If the current year is a leap year and it is currently Adar I or Adar II and the year it is being decreased to is also a leap year, the same Adar will be used. If it is being decreased to a non-leap year, the month will be set to Adar.- Parameters:
years- the number of years to subtractuseAdarAlephForLeapYear- if set to true and the current month is Adar on a non-leap year and it is being subtracted to a leap year, it will be set to Adar I, and if set to false it will set to Adar II. This will be ignored if the month is not set to Adar.- See Also:
-
toString
Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729". For more complex formatting, use the formatter classes. -
equals
-
compareTo
Compares two dates as per the compareTo() method in the Comparable interface. Returns a value less than 0 if this date is "less than" (before) the date, greater than 0 if this date is "greater than" (after) the date, or 0 if they are equal.- Specified by:
compareToin interfaceComparable<JewishDate>
-
getJewishMonth
Returns the Jewish month 1-12 (or 13 years in a leap year). The month count starts with 1 for Nissan and goes to 13 for Adar II- Returns:
- the Jewish month from 1 to 12 (or 13 years in a leap year). The month count starts with 1 for Nissan and goes to 13 for Adar II
-
getJewishDayOfMonth
Returns the Jewish day of month.- Returns:
- the Jewish day of the month
-
getJewishYear
-
getDayOfWeek
Returns the day of the week as a number between 1-7.- Returns:
- the day of the week as a number between 1-7.
-
clone
-
hashCode
-