Class JewishDate

java.lang.Object
com.kosherjava.zmanim.hebrewcalendar.JewishDate
All Implemented Interfaces:
Cloneable, Comparable<JewishDate>
Direct Known Subclasses:
JewishCalendar

public class JewishDate extends Object implements Comparable<JewishDate>, Cloneable
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Value of the month field indicating Adar (or Adar I in a leap 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 Jewish leap 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 long
    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
    A short year where both CHESHVAN and KISLEV are 29 days.
    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 of the Gregorian calendar).
    static 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
    An ordered year where CHESHVAN is 29 days and KISLEV is 30 days.
    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
    A long year where both CHESHVAN and KISLEV are 30 days.
    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

    Constructors
    Constructor
    Description
    Default 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 the LocalDate parameter.
    JewishDate(ZonedDateTime zonedDateTime)
    A constructor that initializes the date to the ZonedDateTime parameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static LocalDate
    absDateToDate(int absDate)
    Computes the Gregorian date from the absolute date.
    private static int
    addDechiyos(int year, int moladDay, int moladParts)
    Adds the 4 dechiyos for molad Tishrei.
    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
    equals(Object object)
    Indicates whether some other object is "equal to" this one.
    int
    Returns the absolute date (days since January 1, 0001 of 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 year, int month)
    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
    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.
    static int
    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)
    Converts the NISSAN based constants used by this class to numeric month starting from TISHREI.
    int
    Returns the Jewish year.
    private static int
    getLastDayOfGregorianMonth(int year, int month)
    Returns the number of days in a given month in a given year and month.
    private static int
    Returns the last month of a given Jewish year.
    Returns this object's date as a LocalDate object.
    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
    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.
    boolean
    Returns if the year the calendar is set to is a Jewish leap year.
    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.
    void
    minusDays(int days)
    Subtracts the number of days passed in from the currently set date.
    void
    minusMonths(int months)
    Subtracts the number of months passed in to the currently set date.
    void
    minusYears(int years, boolean useAdarAlephForLeapYear)
    Subtract the number of years passed in to the currently set 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
    plusDays(int days)
    Add the number of days passed in to the currently set date.
    void
    plusMonths(int months)
    Add the number of months passed in to the currently set date.
    void
    plusYears(int years, boolean useAdarAlephForLeapYear)
    Add the number of years passed in to the currently set date.
    void
    Resets this date to the current system date.
    private void
    setAbsDate(int gregorianAbsDate)
    Computes and sets the Jewish date fields based on the provided absolute (Gregorian) date.
    void
    Sets the date based on a LocalDate object.
    void
    Sets the date based on a ZonedDateTime object.
    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)
    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.
    void
    setJewishMonth(int month)
    Setter for the Jewish month that is passed in.
    void
    setJewishYear(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).
    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.
    Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729".
    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.

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • NISSAN

      public static final int NISSAN
      Value of the month field indicating Nissan, the first numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 7th (or 8th in a leap year) month of the year.
      See Also:
    • IYAR

      public static final int IYAR
      Value of the month field indicating Iyar, the second numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 8th (or 9th in a leap year) month of the year.
      See Also:
    • SIVAN

      public static final int SIVAN
      Value of the month field indicating Sivan, the third numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 9th (or 10th in a leap year) month of the year.
      See Also:
    • TAMMUZ

      public static final int TAMMUZ
      Value of the month field indicating Tammuz, the fourth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 10th (or 11th in a leap year) month of the year.
      See Also:
    • AV

      public static final int AV
      Value of the month field indicating Av, the fifth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 11th (or 12th in a leap year) month of the year.
      See Also:
    • ELUL

      public static final int ELUL
      Value of the month field indicating Elul, the sixth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 12th (or 13th in a leap year) month of the year.
      See Also:
    • TISHREI

      public static final int 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

      public static final int CHESHVAN
      Value of the month field indicating Cheshvan/marcheshvan, the eighth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 2nd month of the year.
      See Also:
    • KISLEV

      public static final int KISLEV
      Value of the month field indicating Kislev, the ninth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 3rd month of the year.
      See Also:
    • TEVES

      public static final int TEVES
      Value of the month field indicating Teves, the tenth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 4th month of the year.
      See Also:
    • SHEVAT

      public static final int SHEVAT
      Value of the month field indicating Shevat, the eleventh numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 5th month of the year.
      See Also:
    • ADAR

      public static final int ADAR
      Value of the month field indicating Adar (or Adar I in a leap year), the twelfth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 6th month of the year.
      See Also:
    • ADAR_II

      public static final int ADAR_II
      Value of the month field indicating Adar II, the leap (intercalary or embolismic) thirteenth (Undecimber) numeric month of the year added in Jewish leap year). The leap years are years 3, 6, 8, 11, 14, 17 and 19 of a 19-year cycle. With the year starting at TISHREI, it would actually be the 7th month of the year.
      See Also:
    • JEWISH_EPOCH

      private static final int 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

      private static final int CHALAKIM_PER_MINUTE
      The number of chalakim (18) in a minute.
      See Also:
    • CHALAKIM_PER_HOUR

      private static final int CHALAKIM_PER_HOUR
      The number of chalakim (1080) in an hour.
      See Also:
    • CHALAKIM_PER_DAY

      private static final long CHALAKIM_PER_DAY
      The number of chalakim (25,920) in a 24-hour day .
      See Also:
    • CHALAKIM_PER_MONTH

      private static final long 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

      private static final int 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

      public static final int CHASERIM
      A short year where both CHESHVAN and KISLEV are 29 days.
      See Also:
    • KESIDRAN

      public static final int KESIDRAN
      An ordered year where CHESHVAN is 29 days and KISLEV is 30 days.
      See Also:
    • SHELAIMIM

      public static final int SHELAIMIM
      A long year where both CHESHVAN and KISLEV are 30 days.
      See Also:
    • jewishMonth

      private int jewishMonth
      the internal Jewish month.
    • jewishDay

      private int jewishDay
      the internal Jewish day.
    • jewishYear

      private int jewishYear
      the internal Jewish year.
    • moladHours

      private int moladHours
      the internal count of molad hours.
    • moladMinutes

      private int moladMinutes
      the internal count of molad minutes.
    • moladChalakim

      private int moladChalakim
      the internal count of molad chalakim.
    • dayOfWeek

      private int dayOfWeek
      1 == Sunday, 2 == Monday, etc...
    • gregorianAbsDate

      private int gregorianAbsDate
      Returns the absolute date (days since January 1, 0001 of the Gregorian calendar).
      See Also:
  • Constructor Details

    • JewishDate

      public JewishDate(long molad)
      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

      public JewishDate(int jewishYear, int jewishMonth, int jewishDayOfMonth)
      Creates a Jewish date based on a Jewish year, month and day of month.
      Parameters:
      jewishYear - the Jewish year
      jewishMonth - the Jewish month. The method expects a 1 for Nissan ... 12 for Adar and 13 for Adar II. Use the constants NISSAN ... ADAR (or ADAR_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 example IYAR, or KISLEV in a year that isKislevShort()), 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

      public JewishDate(ZonedDateTime zonedDateTime)
      A constructor that initializes the date to the ZonedDateTime parameter.
      Parameters:
      zonedDateTime - the ZonedDateTime to set the calendar to
    • JewishDate

      public JewishDate(LocalDate localDate)
      A constructor that initializes the date to the LocalDate parameter.
      Parameters:
      localDate - the LocalDate to set the calendar to
  • Method Details

    • getMoladHours

      public int getMoladHours()
      Returns the molad hours. Only a JewishDate object populated with getMolad(), setJewishDate(int, int, int, int, int, int) or setMoladHours(int) will have this field populated. A regular JewishDate object will have this field set to 0.
      Returns:
      the molad hours
      See Also:
    • setMoladHours

      public void setMoladHours(int moladHours)
      Sets the molad hours.
      Parameters:
      moladHours - the molad hours to set
      See Also:
    • getMoladMinutes

      public int getMoladMinutes()
      Returns the molad minutes. Only an object populated with getMolad(), setJewishDate(int, int, int, int, int, int) or or setMoladMinutes(int) will have these fields populated. A regular JewishDate object will have this field set to 0.
      Returns:
      the molad minutes
      See Also:
    • setMoladMinutes

      public void setMoladMinutes(int moladMinutes)
      Sets the molad minutes. The expectation is that the traditional minute-less chalakim will be broken out to minutes and chalakim / 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

      public void setMoladChalakim(int moladChalakim)
      Sets the molad chalakim/parts. The expectation is that the traditional minute-less chalakim will be broken out to minutes 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

      public int getMoladChalakim()
      Returns the molad chalakim / parts. Only an object populated with getMolad(), setJewishDate(int, int, int, int, int, int) or or setMoladChalakim(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

      private static int getLastDayOfGregorianMonth(int year, int month)
      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

      private static LocalDate absDateToDate(int absDate)
      Computes the Gregorian date from the absolute date. ND+ER
      Parameters:
      absDate - the absolute date
      Returns:
      the LocalDate.
    • getAbsDate

      public int getAbsDate()
      Returns the absolute date (days since January 1, 0001 of the Gregorian calendar).
      Returns:
      the number of days since January 1, 1
    • gregorianDateToAbsDate

      private static int gregorianDateToAbsDate(int year, int month, int dayOfMonth)
      Computes the absolute date from a Gregorian date. ND+ER
      Parameters:
      year - the Gregorian year
      month - the Gregorian month. Unlike the Java Calendar where January has the value of 0,This expects a 1 for January
      dayOfMonth - the day of the month (1st, 2nd, etc...)
      Returns:
      the absolute Gregorian day
    • isJewishLeapYear

      public static boolean isJewishLeapYear(int year)
      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

      public boolean 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

      private static int getLastMonthOfJewishYear(int year)
      Returns the last month of a given Jewish year. This will be 12 on a non leap 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

      public 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.
      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

      private static int addDechiyos(int year, int moladDay, int moladParts)
      Adds the 4 dechiyos for molad Tishrei. These are:
      1. 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.
      2. 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.
      3. 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)
      4. 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 year
      moladDay - the molad day
      moladParts - the molad parts
      Returns:
      the number of elapsed days in the JewishCalendar adjusted for the 4 dechiyos.
    • getChalakimSinceMoladTohu

      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.
      Parameters:
      year - the Jewish year
      month - the Jewish month the Jewish month, with the month numbers starting from Nissan. Use the JewishDate constants such as TISHREI.
      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

      private static int getJewishMonthOfYear(int year, int month)
      Converts the NISSAN based constants used by this class to numeric month starting from TISHREI. This is required for molad calculations.
      Parameters:
      year - The Jewish year
      month - 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 an IllegalArgumentException if the Jewish date is 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).
      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 > 23
      minutes - the minutes (for molad calculations). It will reject a minute < 0 or > 59
      chalakim - 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

      public static int getDaysInJewishYear(int year)
      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

      public int 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

      private static boolean isCheshvanLong(int year)
      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

      public boolean 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

      private static boolean isKislevShort(int year)
      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

      public boolean 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

      public int getCheshvanKislevKviah()
      Returns the Cheshvan and Kislev kviah (whether a Jewish year is short, regular or long). It will return SHELAIMIM if both cheshvan and kislev are 30 days, KESIDRAN if Cheshvan is 29 days and Kislev is 30 days and CHASERIM if both are 29 days.
      Returns:
      SHELAIMIM if both cheshvan and kislev are 30 days, KESIDRAN if Cheshvan is 29 days and Kislev is 30 days and CHASERIM if both are 29 days.
      See Also:
    • getDaysInJewishMonth

      private static int getDaysInJewishMonth(int year, int month)
      Returns the number of days of a Jewish month for a given month and year.
      Parameters:
      year - the Jewish Year
      month - the Jewish month
      Returns:
      the number of days for a given Jewish month
    • getDaysInJewishMonth

      public int 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

      private void setAbsDate(int gregorianAbsDate)
      Computes and sets the Jewish date fields based on the provided absolute (Gregorian) date.
      Parameters:
      gregorianAbsDate - the Gregorian absolute date.
    • jewishDateToAbsDate

      private static int jewishDateToAbsDate(int year, int month, int dayOfMonth)
      Returns the absolute date of Jewish date. ND+ER
      Parameters:
      year - the Jewish year. The year can't be negative
      month - 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 constants NISSAN 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

      public JewishDate getMolad()
      Returns the molad for a given year and month. Returns a JewishDate Object set to the date of the molad with the hours, minutes and chalakim 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.
      Returns:
      a JewishDate Object set to the date of the molad with the hours, minutes and chalakim set.
    • moladToAbsDate

      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.
      Parameters:
      chalakim - the number of chalakim since the beginning of Sunday prior to BaHaRaD
      Returns:
      the number of days from the Jewish epoch
    • getDaysSinceStartOfJewishYear

      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.
      Parameters:
      year - the Jewish year
      month - the Jewish month
      dayOfMonth - 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

      public void setGregorianDate(ZonedDateTime zonedDateTime)
      Sets the date based on a ZonedDateTime object. Modifies the Jewish date as well.
      Parameters:
      zonedDateTime - the ZonedDateTime to set the calendar to
    • setGregorianDate

      public void setGregorianDate(LocalDate localDate)
      Sets the date based on a LocalDate object. Modifies the Jewish date as well.
      Parameters:
      localDate - the LocalDate to set the calendar to
      Throws:
      IllegalArgumentException - if the date would fall prior to the year 1 AD
    • setJewishDate

      public void setJewishDate(int year, int month, int dayOfMonth)
      Sets the Jewish Date and updates the Gregorian date accordingly.
      Parameters:
      year - the Jewish year. The year can't be negative
      month - the Jewish month starting with Nissan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for Adar II. Use the constants NISSAN ... ADAR (or ADAR_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 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 negative
      month - the Jewish month starting with Nissan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for Adar II. Use the constants NISSAN ... ADAR (or ADAR_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 calculations
      minutes - the minutes. Used for molad calculations
      chalakim - 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

      public void setJewishDayOfMonth(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.
      Parameters:
      dayOfMonth - the day of the month to set the date to.
    • setJewishMonth

      public void setJewishMonth(int month)
      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

      public void setJewishYear(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). 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 as CHESHVAN or KISLEV or ADAR I on 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

      Returns this object's date as a LocalDate object.
      Returns:
      The LocalDate
    • resetDate

      public void resetDate()
      Resets this date to the current system date.
    • minusDays

      public void minusDays(int days)
      Subtracts the number of days passed in from the currently set date.
      Parameters:
      days - the number of days to subtract.
      See Also:
    • plusDays

      public void plusDays(int days)
      Add the number of days passed in to the currently set date.
      Parameters:
      days - the number of days to add.
      See Also:
    • plusMonths

      public void plusMonths(int months)
      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

      public void minusMonths(int months)
      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

      public void plusYears(int years, boolean useAdarAlephForLeapYear)
      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, passing true to the useAdarAlephForLeapYear parameter will set the month to Adar I, and passing false will 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 add
      useAdarAlephForLeapYear - 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

      public void minusYears(int years, boolean useAdarAlephForLeapYear)
      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, passing true to the useAdarAlephForLeapYear parameter will set the month to Adar I, and passing false will 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 subtract
      useAdarAlephForLeapYear - 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

      public String 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.
      Overrides:
      toString in class Object
      Returns:
      the Jewish date in the form "day Month, year" e.g. "21 Shevat, 5729"
      See Also:
    • equals

      public boolean equals(Object object)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object
      See Also:
    • compareTo

      public int compareTo(JewishDate jewishDate)
      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 interface Comparable<JewishDate>
    • getJewishMonth

      public int 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

      public int getJewishDayOfMonth()
      Returns the Jewish day of month.
      Returns:
      the Jewish day of the month
    • getJewishYear

      public int getJewishYear()
      Returns the Jewish year.
      Returns:
      the Jewish year
    • getDayOfWeek

      public int 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

      public Object clone()
      A method that creates a deep copy of the object.
      Overrides:
      clone in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also: