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 - 2021
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Value 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 int
Value 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 int
Value of the month field indicating Av, the fifth numeric month of the year in the Jewish calendar.private static final int
Days from the beginning of Sunday till molad BaHaRaD.private static final int
The number of chalakim (25,920) in a 24 hour day .private static final int
The number of chalakim (1080) in an hour.private static final int
The number of chalakim (18) in a minute.private static final long
The number of chalakim in an average Jewish month.static final int
static final int
Value of the month field indicating Cheshvan/marcheshvan, the eighth numeric month of the year in the Jewish calendar.private int
1 == Sunday, 2 == Monday, etc...static final int
Value of the month field indicating Elul, the sixth numeric month of the year in the Jewish calendar.private int
Returns the absolute date (days since January 1, 0001 on the Gregorian calendar).private int
The day of the Gregorian monthprivate int
The month, where 1 == January, 2 == February, etc...private int
The Gregorian yearstatic final int
Value of the month field indicating Iyar, the second numeric month of the year in the Jewish calendar.private static final int
the Jewish epoch using the RD (Rata Die/Fixed Date or Reingold Dershowitz) day used in Calendrical Calculations.private int
the internal Jewish day.private int
the internal Jewish month.private int
the internal Jewish year.static final int
static final int
Value of the month field indicating Kislev, the ninth numeric month of the year in the Jewish calendar.private int
the internal count of molad chalakim.private int
the internal count of molad hours.private int
the internal count of molad minutes.static final int
Value of the month field indicating Nissan, the first numeric month of the year in the Jewish calendar.static final int
static final int
Value of the month field indicating Shevat, the eleventh numeric month of the year in the Jewish calendar.static final int
Value of the month field indicating Sivan, the third numeric month of the year in the Jewish calendar.static final int
Value of the month field indicating Tammuz, the fourth numeric month of the year in the Jewish calendar.static final int
Value of the month field indicating Teves, the tenth numeric month of the year in the Jewish calendar.static final int
Value of the month field indicating Tishrei, the seventh numeric month of the year in the Jewish calendar. -
Constructor Summary
ConstructorDescriptionDefault 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 theLocalDate
paremeter.JewishDate
(Calendar calendar) A constructor that initializes the date to theCalendar
paremeter.JewishDate
(Date date) A constructor that initializes the date to theDate
paremeter. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
absDateToDate
(int absDate) Computes the Gregorian date from the absolute date.private void
Computes the Jewish date from the absolute date.private static int
addDechiyos
(int year, int moladDay, int moladParts) Adds the 4 dechiyos for molad Tishrei.void
back()
Rolls the date back by 1 day.clone()
A method that creates a deep copy of the object.int
compareTo
(JewishDate jewishDate) Compares two dates as per the compareTo() method in the Comparable interface.boolean
Indicates whether some other object is "equal to" this one.void
forward
(int field, int amount) Rolls the date, month or year forward by the amount passed in.private void
forwardJewishMonth
(int amount) Forward the Jewish date by the number of months passed in.int
Returns the absolute date (days since January 1, 0001 on the Gregorian calendar).long
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.private static long
getChalakimSinceMoladTohu
(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.int
Returns the Cheshvan and Kislev kviah (whether a Jewish year is short, regular or long).int
Returns the day of the week as a number between 1-7.int
Returns the number of days of the Jewish month that the calendar is currently set to.private static int
getDaysInJewishMonth
(int month, int year) Returns the number of days of a Jewish month for a given month and year.int
Returns the number of days for the current year that the calendar is set to.static int
getDaysInJewishYear
(int year) Returns the number of days for a given Jewish year.int
returns the number of days from Rosh Hashana of the date passed in, to the full date passed in.private static int
getDaysSinceStartOfJewishYear
(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 aCalendar
object.int
Returns the Gregorian day of the month.int
Returns the Gregorian month (between 0-11).int
Returns the Gregotian year.static int
getJewishCalendarElapsedDays
(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.int
Returns the Jewish day of month.int
Returns the Jewish month 1-12 (or 13 years in a leap year).private static int
getJewishMonthOfYear
(int year, int month) int
Returns the Jewish year.(package private) int
getLastDayOfGregorianMonth
(int month) Returns the last day in a gregorian monthprivate static int
getLastDayOfGregorianMonth
(int month, int year) Returns the number of days in a given month in a given month and year.private static int
getLastMonthOfJewishYear
(int year) Returns the last month of a given Jewish year.Returns this object's date as aLocalDate
object.getMolad()
Returns the molad for a given year and month.int
Returns the molad chalakim/parts.int
Returns the molad hours.int
Returns the molad minutes.private static int
gregorianDateToAbsDate
(int year, int month, int dayOfMonth) Computes the absolute date from a Gregorian date.int
hashCode()
OverridesObject.hashCode()
.boolean
Returns if Cheshvan is long (30 days VS 29 days) for the current year that the calendar is set to.private static boolean
isCheshvanLong
(int year) Returns if Cheshvan is long in a given Jewish year.(package private) boolean
isGregorianLeapYear
(int year) Returns is the year passed in is a Gregorian leap year.boolean
Returns if the year the calendar is set to is a Jewish leap year.private static boolean
isJewishLeapYear
(int year) Returns if the year is a Jewish leap year.boolean
Returns if the Kislev is short for the year that this class is set to.private static boolean
isKislevShort
(int year) Returns if Kislev is short (29 days VS 30 days) in a given Jewish year.private static int
jewishDateToAbsDate
(int year, int month, int dayOfMonth) Returns the absolute date of Jewish date.private static int
moladToAbsDate
(long chalakim) Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in.void
Resets this date to the current system date.void
Sets the date based on aLocalDate
object.void
Sets the date based on aCalendar
object.void
Sets the date based on aDate
object.void
setGregorianDate
(int year, int month, int dayOfMonth) Sets the Gregorian Date, and updates the Jewish date accordingly.void
setGregorianDayOfMonth
(int dayOfMonth) sets the Gregorian Day of month.void
setGregorianMonth
(int month) Sets the Gregorian month.void
setGregorianYear
(int year) sets the Gregorian year.private void
setInternalGregorianDate
(int year, int month, int dayOfMonth) Sets the hidden internal representation of the Gregorian date , and updates the Jewish date accordingly.void
setJewishDate
(int year, int month, int dayOfMonth) Sets the Jewish Date and updates the Gregorian date accordingly.void
setJewishDate
(int year, int month, int dayOfMonth, int hours, int minutes, int chalakim) Sets the Jewish Date and updates the Gregorian date accordingly.void
setJewishDayOfMonth
(int dayOfMonth) sets the Jewish day of month.void
setJewishMonth
(int month) sets the Jewish month.void
setJewishYear
(int year) sets the Jewish year.void
setMoladChalakim
(int moladChalakim) Sets the molad chalakim/parts.void
setMoladHours
(int moladHours) Sets the molad hours.void
setMoladMinutes
(int moladMinutes) Sets the molad minutes.private void
setMoladTime
(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 void
validateGregorianDate
(int year, int month, int dayOfMonth) Validates the components of a Gregorian date for validity.private static void
validateGregorianDayOfMonth
(int dayOfMonth) Validates a Gregorian day of month for validity.private static void
validateGregorianMonth
(int month) Validates a Gregorian month for validity.private static void
validateGregorianYear
(int year) Validates a Gregorian year for validity.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.
-
Field Details
-
NISSAN
Value of the month field indicating Nissan, the first numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 7th (or 8th in aleap year
) month of the year.- See Also:
-
IYAR
Value of the month field indicating Iyar, the second numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 8th (or 9th in aleap year
) month of the year.- See Also:
-
SIVAN
Value of the month field indicating Sivan, the third numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 9th (or 10th in aleap year
) month of the year.- See Also:
-
TAMMUZ
Value of the month field indicating Tammuz, the fourth numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 10th (or 11th in aleap year
) month of the year.- See Also:
-
AV
Value of the month field indicating Av, the fifth numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 11th (or 12th in aleap year
) month of the year.- See Also:
-
ELUL
Value of the month field indicating Elul, the sixth numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 12th (or 13th in aleap year
) month of the year.- See Also:
-
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
Value of the month field indicating Cheshvan/marcheshvan, the eighth numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 2nd month of the year.- See Also:
-
KISLEV
Value of the month field indicating Kislev, the ninth numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 3rd month of the year.- See Also:
-
TEVES
Value of the month field indicating Teves, the tenth numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 4th month of the year.- See Also:
-
SHEVAT
Value of the month field indicating Shevat, the eleventh numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 5th month of the year.- See Also:
-
ADAR
Value of the month field indicating Adar (or Adar I in aleap year
), the twelfth numeric month of the year in the Jewish calendar. With the year starting atTISHREI
, it would actually be the 6th month of the year.- See Also:
-
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 Gregorian- See Also:
-
CHALAKIM_PER_MINUTE
The number of chalakim (18) in a minute.- See Also:
-
CHALAKIM_PER_HOUR
The number of chalakim (1080) in an hour.- See Also:
-
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 the 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 on 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_II
for 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
, orKISLEV
in 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 theDate
paremeter.- Parameters:
date
- theDate
to 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 theCalendar
paremeter.- Parameters:
calendar
- theCalendar
to set the calendar to- Throws:
IllegalArgumentException
- if theCalendar.ERA
isGregorianCalendar.BC
-
JewishDate
A constructor that initializes the date to theLocalDate
paremeter.- Parameters:
localDate
- theLocalDate
to set the calendar to- Throws:
IllegalArgumentException
- if theCalendar.ERA
isGregorianCalendar.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 tominutes
and 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 on 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 year
or 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 204 chalakim (TRaD) it is delayed till Thursday (one day delay, plus one day for Lo ADU Rosh)
- BeTuTaKFoT - if the year following a leap year falls on a Monday (Be) on or after 15 hours (Tu) and 589 chalakim (TaKFoT) 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 Nisan. 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
Converts theNISSAN
based constants used by this class to numeric month starting fromTISHREI
. This is required for Molad claculations.- Parameters:
year
- The Jewish yearmonth
- The Jewish Month- Returns:
- the Jewish month of the year starting with Tishrei
-
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 anIllegalArgumentException
if 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 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 anIllegalArgumentException
if 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.JANUARY
has 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.JANUARY
has 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
Returns the Cheshvan and Kislev kviah (whether a Jewish year is short, regular or long). It will returnSHELAIMIM
if both cheshvan and kislev are 30 days,KESIDRAN
if Cheshvan is 29 days and Kislev is 30 days andCHASERIM
if both are 29 days. -
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 Nisan. Nisan expects a value of 1 etc till Adar with a value of 12. For a leap year, 13 will be the expected value for Adar II. Use the constantsNISSAN
etc.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 JewishDateObject
set to the date of the molad with thehours
,minutes
andchalakim
set. 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 aCalendar
object. Modifies the Jewish date as well.- Parameters:
calendar
- theCalendar
to set the calendar to- Throws:
IllegalArgumentException
- if theCalendar.ERA
isGregorianCalendar.BC
-
setDate
Sets the date based on aDate
object. Modifies the Jewish date as well.- Parameters:
date
- theDate
to set the calendar to- Throws:
IllegalArgumentException
- if the date would fall prior to the year 1 AD
-
setDate
Sets the date based on aLocalDate
object. Modifies the Jewish date as well.- Parameters:
localDate
- theLocalDate
to 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 Nisan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for Adar II. Use the constantsNISSAN
...ADAR
(orADAR_II
for 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 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 Nisan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for Adar II. Use the constantsNISSAN
...ADAR
(orADAR_II
for 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 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
Returns this object's date as aCalendar
object.- Returns:
- The
Calendar
-
getLocalDate
Returns this object's date as aLocalDate
object.- Returns:
- The
LocalDate
-
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 theCalendar
classCalendar.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.MONTH
orCalendar.YEAR
amount
- the positive amount to move forward- Throws:
IllegalArgumentException
- if the field is anything besidesCalendar.DATE
,Calendar.MONTH
orCalendar.YEAR
or 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 Nisan 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 theCalendar
classCalendar.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
-
equals
Indicates whether some other object is "equal to" this one. -
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:
compareTo
in 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
Returns the Gregotian year.- Returns:
- the Gregorian year
-
getJewishMonth
Returns the Jewish month 1-12 (or 13 years in a leap year). The month count starts with 1 for Nisan 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 Nisan and goes to 13 for Adar II
-
getJewishDayOfMonth
Returns the Jewish day of month.- Returns:
- the Jewish day of the month
-
getJewishYear
Returns the Jewish year.- Returns:
- the Jewish year
-
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 Nisan 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 (preior 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
A method that creates a deep copy of the object. -
hashCode
OverridesObject.hashCode()
.
-