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
GregorianCalendar
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, © Eliyahu Hershfeld 2011 - 2024
- 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 intThe 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).private intThe day of the Gregorian monthprivate intThe month, where 1 == January, 2 == February, etc...private intThe Gregorian yearstatic 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(Calendar calendar) A constructor that initializes the date to theCalendarparameter.JewishDate(Date date) A constructor that initializes the date to theDateparameter. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidabsDateToDate(int absDate) Computes the Gregorian date from the absolute date.private voidComputes the Jewish date from the absolute date.private static intaddDechiyos(int year, int moladDay, int moladParts) Adds the 4 dechiyos for molad Tishrei.voidback()Rolls the date back by 1 day.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.voidforward(int field, int amount) Rolls the date, month or year forward by the amount passed in.private voidforwardJewishMonth(int amount) Forward the Jewish date by the number of months passed in.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 month, int year) 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.Returns this object's date as aCalendarobject.intReturns the Gregorian day of the month.intReturns the Gregorian month (between 0-11).intReturns the Gregorian year.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.(package private) intgetLastDayOfGregorianMonth(int month) Returns the last day in a gregorian monthprivate static intgetLastDayOfGregorianMonth(int month, int year) Returns the number of days in a given month in a given month and year.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.(package private) booleanisGregorianLeapYear(int year) Returns is the year passed in is a Gregorian leap year.booleanReturns if the year the calendar is set to is a Jewish leap year.private 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.private static intmoladToAbsDate(long chalakim) Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in.voidResets this date to the current system date.voidSets the date based on aLocalDateobject.voidSets the date based on aCalendarobject.voidSets the date based on aDateobject.voidsetGregorianDate(int year, int month, int dayOfMonth) Sets the Gregorian Date, and updates the Jewish date accordingly.voidsetGregorianDayOfMonth(int dayOfMonth) sets the Gregorian Day of month.voidsetGregorianMonth(int month) Sets the Gregorian month.voidsetGregorianYear(int year) sets the Gregorian year.private voidsetInternalGregorianDate(int year, int month, int dayOfMonth) Sets the hidden internal representation of the Gregorian date , and updates the Jewish date accordingly.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) sets the Jewish day of month.voidsetJewishMonth(int month) sets the Jewish month.voidsetJewishYear(int year) sets the Jewish year.voidsetMoladChalakim(int moladChalakim) Sets the molad chalakim/parts.voidsetMoladHours(int moladHours) Sets the molad hours.voidsetMoladMinutes(int moladMinutes) Sets the molad minutes.private voidsetMoladTime(int chalakim) Sets the molad time (hours minutes and chalakim) based on the number of chalakim since the start of the day.toString()Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729".private static voidvalidateGregorianDate(int year, int month, int dayOfMonth) Validates the components of a Gregorian date for validity.private static voidvalidateGregorianDayOfMonth(int dayOfMonth) Validates a Gregorian day of month for validity.private static voidvalidateGregorianMonth(int month) Validates a Gregorian month for validity.private static voidvalidateGregorianYear(int year) Validates a Gregorian year for validity.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. -
gregorianMonth
The month, where 1 == January, 2 == February, etc... Note that this is different than Java's Calendar class where January == 0. -
gregorianDayOfMonth
The day of the Gregorian month -
gregorianYear
The Gregorian year -
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 theDateparameter.- Parameters:
date- theDateto set the calendar to- Throws:
IllegalArgumentException- if the date would fall prior to the January 1, 1 AD
-
JewishDate
A constructor that initializes the date to theCalendarparameter.- Parameters:
calendar- theCalendarto set the calendar to- Throws:
IllegalArgumentException- if theCalendar.ERAisGregorianCalendar.BC
-
JewishDate
A constructor that initializes the date to theLocalDateparameter.- Parameters:
localDate- theLocalDateto set the calendar to- Throws:
IllegalArgumentException- if theCalendar.ERAisGregorianCalendar.BC
-
-
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 last day in a gregorian month- Parameters:
month- the Gregorian month- Returns:
- the last day of the Gregorian month
-
isGregorianLeapYear
Returns is the year passed in is a Gregorian leap year.- Parameters:
year- the Gregorian year- Returns:
- if the year in question is a leap year.
-
getLastDayOfGregorianMonth
Returns the number of days in a given month in a given month and year.- Parameters:
month- the month. As with other cases in this class, this is 1-based, not zero-based.year- the year (only impacts February)- 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
-
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).
-
validateGregorianDate
Validates the components of a Gregorian date for validity. It will throw anIllegalArgumentExceptionif a year of < 1, a month < 0 or > 11 or a day of month < 1 is passed in.- Parameters:
year- the Gregorian year to validate. It will reject any year < 1.month- the Gregorian month number to validate. It will enforce that the month is between 0 - 11 like aGregorianCalendar, whereCalendar.JANUARYhas a value of 0.dayOfMonth- the day of the Gregorian month to validate. It will reject any value < 1, but will allow values > 31 since calling methods will simply set it to the maximum for that month. TODO: check calling methods to see if there is any reason that the class needs days > the maximum.- Throws:
IllegalArgumentException- if a year of < 1, a month < 0 or > 11 or a day of month < 1 is passed in- See Also:
-
validateGregorianMonth
Validates a Gregorian month for validity.- Parameters:
month- the Gregorian month number to validate. It will enforce that the month is between 0 - 11 like aGregorianCalendar, whereCalendar.JANUARYhas a value of 0.
-
validateGregorianDayOfMonth
Validates a Gregorian day of month for validity.- Parameters:
dayOfMonth- the day of the Gregorian month to validate. It will reject any value < 1, but will allow values > 31 since calling methods will simply set it to the maximum for that month. TODO: check calling methods to see if there is any reason that the class needs days > the maximum.
-
validateGregorianYear
Validates a Gregorian year for validity.- Parameters:
year- the Gregorian year to validate. It will reject any year < 1.
-
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:
month- the Jewish monthyear- the Jewish Year- 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.
-
absDateToJewishDate
Computes the Jewish date from the 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
-
setMoladTime
Sets the molad time (hours minutes and chalakim) based on the number of chalakim since the start of the day.- Parameters:
chalakim- the number of chalakim since the start of the day.
-
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
-
setDate
Sets the date based on aCalendarobject. Modifies the Jewish date as well.- Parameters:
calendar- theCalendarto set the calendar to- Throws:
IllegalArgumentException- if theCalendar.ERAisGregorianCalendar.BC
-
setDate
Sets the date based on aDateobject. Modifies the Jewish date as well.- Parameters:
date- theDateto set the calendar to- Throws:
IllegalArgumentException- if the date would fall prior to the year 1 AD
-
setDate
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
-
setGregorianDate
Sets the Gregorian Date, and updates the Jewish date accordingly. Like the Java Calendar A value of 0 is expected for January.- Parameters:
year- the Gregorian yearmonth- the Gregorian month. Like the Java Calendar, this class expects 0 for JanuarydayOfMonth- the Gregorian day of month. If this is > the number of days in the month/year, the last valid date of the month will be set- Throws:
IllegalArgumentException- if a year of < 1, a month < 0 or > 11 or a day of month < 1 is passed in
-
setInternalGregorianDate
Sets the hidden internal representation of the Gregorian date , and updates the Jewish date accordingly. While public getters and setters have 0 based months matching the Java Calendar classes, This class internally represents the Gregorian month starting at 1. When this is called it will not adjust the month to match the Java Calendar classes.- Parameters:
year- the yearmonth- the monthdayOfMonth- the day of month
-
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).
-
getGregorianCalendar
-
getLocalDate
-
resetDate
Resets this date to the current system date. -
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. -
forward
Rolls the date, month or year forward by the amount passed in. It modifies both the Gregorian and Jewish dates accordingly. If manipulation beyond the fields supported here is required, use theCalendarclassCalendar.add(int, int)orCalendar.roll(int, int)methods in the following manner.Calendar cal = jewishDate.getTime(); // get a java.util.Calendar representation of the JewishDate cal.add(Calendar.MONTH, 3); // add 3 Gregorian months jewishDate.setDate(cal); // set the updated calendar back to this class- Parameters:
field- the calendar field to be forwarded. The must beCalendar.DATE,Calendar.MONTHorCalendar.YEARamount- the positive amount to move forward- Throws:
IllegalArgumentException- if the field is anything besidesCalendar.DATE,Calendar.MONTHorCalendar.YEARor if the amount is less than 1- See Also:
-
forwardJewishMonth
Forward the Jewish date by the number of months passed in. FIXME: Deal with forwarding a date such as 30 Nissan by a month. 30 Iyar does not exist. This should be dealt with similar to the way that the Java Calendar behaves (not that simple since there is a difference between add() or roll().- Parameters:
amount- the number of months to roll the month forward- Throws:
IllegalArgumentException- if the amount is less than 1
-
back
Rolls the date back by 1 day. It modifies both the Gregorian and Jewish dates accordingly. The API does not currently offer the ability to forward more than one day at a time, or to forward by month or year. If such manipulation is required use theCalendarclassCalendar.add(int, int)orCalendar.roll(int, int)methods in the following manner.Calendar cal = jewishDate.getTime(); // get a java.util.Calendar representation of the JewishDate cal.add(Calendar.MONTH, -3); // subtract 3 Gregorian months jewishDate.setDate(cal); // set the updated calendar back to this class- See Also:
-
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>
-
getGregorianMonth
Returns the Gregorian month (between 0-11).- Returns:
- the Gregorian month (between 0-11). Like the java.util.Calendar, months are 0 based.
-
getGregorianDayOfMonth
Returns the Gregorian day of the month.- Returns:
- the Gregorian day of the mont
-
getGregorianYear
-
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.
-
setGregorianMonth
Sets the Gregorian month.- Parameters:
month- the Gregorian month- Throws:
IllegalArgumentException- if a month < 0 or > 11 is passed in
-
setGregorianYear
sets the Gregorian year.- Parameters:
year- the Gregorian year.- Throws:
IllegalArgumentException- if a year of < 1 is passed in
-
setGregorianDayOfMonth
sets the Gregorian Day of month.- Parameters:
dayOfMonth- the Gregorian Day of month.- Throws:
IllegalArgumentException- if the day of month of < 1 is passed in
-
setJewishMonth
sets the Jewish month.- Parameters:
month- 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- Throws:
IllegalArgumentException- if a month < 1 or > 12 (or 13 on a leap year) is passed in
-
setJewishYear
sets the Jewish year.- Parameters:
year- the Jewish year- Throws:
IllegalArgumentException- if a year of < 3761 is passed in. The same will happen if the year is 3761 and the month and day previously set are < 18 Teves (prior to Jan 1, 1 AD)
-
setJewishDayOfMonth
sets the Jewish day of month.- Parameters:
dayOfMonth- the Jewish day of month- Throws:
IllegalArgumentException- if the day of month is < 1 or > 30 is passed in
-
clone
-
hashCode
-