Class JewishCalendar

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

public class JewishCalendar
extends JewishDate
The JewishCalendar extends the JewishDate class and adds calendar methods. This open source Java code was originally ported 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. The class allows setting whether the holiday and parsha scheme follows the Israel scheme or outside Israel scheme. The default is the outside Israel scheme. The parsha code was ported by Y. Paritcher from his libzmanim code.
Author:
© Y. Paritcher 2019, © Avrom Finkelstien 2002, © Eliyahu Hershfeld 2011 - 2020
See Also:
Date, Calendar
TODO:
Some do not belong in this class, but here is a partial list of what should still be implemented in some form:
  1. Add Isru Chag
  2. Mishna yomis etc
  • Field Details

  • Constructor Details

    • JewishCalendar

      public JewishCalendar()
      Default constructor will set a default date to the current system date.
    • JewishCalendar

      public JewishCalendar​(Date date)
      A constructor that initializes the date to the Date parameter.
      Parameters:
      date - the Date to set the calendar to
    • JewishCalendar

      public JewishCalendar​(Calendar calendar)
      A constructor that initializes the date to the Calendar parameter.
      Parameters:
      calendar - the Calendar to set the calendar to
    • JewishCalendar

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

      public JewishCalendar​(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 JewishDate.NISSAN ... JewishDate.ADAR (or JewishDate.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 JewishDate.IYAR, or JewishDate.KISLEV in a year that JewishDate.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.
    • JewishCalendar

      public JewishCalendar​(int jewishYear, int jewishMonth, int jewishDayOfMonth, boolean inIsrael)
      Creates a Jewish date based on a Jewish date and whether in Israel
      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 JewishDate.NISSAN ... JewishDate.ADAR (or JewishDate.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 JewishDate.IYAR, or JewishDate.KISLEV in a year that JewishDate.isKislevShort()), the 29th (last valid date of the month) will be set
      inIsrael - whether in Israel. This affects Yom Tov calculations
  • Method Details

    • isUseModernHolidays

      public boolean isUseModernHolidays()
      Is this calendar set to return modern Israeli national holidays. By default this value is false. The holidays are: "Yom HaShoah", "Yom Hazikaron", "Yom Ha'atzmaut" and "Yom Yerushalayim"
      Returns:
      the useModernHolidays true if set to return modern Israeli national holidays
    • setUseModernHolidays

      public void setUseModernHolidays​(boolean useModernHolidays)
      Seth the calendar to return modern Israeli national holidays. By default this value is false. The holidays are: "Yom HaShoah", "Yom Hazikaron", "Yom Ha'atzmaut" and "Yom Yerushalayim"
      Parameters:
      useModernHolidays - the useModernHolidays to set
    • setInIsrael

      public void setInIsrael​(boolean inIsrael)
      Sets whether to use Israel holiday scheme or not. Default is false.
      Parameters:
      inIsrael - set to true for calculations for Israel
    • getInIsrael

      public boolean getInIsrael()
      Gets whether Israel holiday scheme is used or not. The default (if not set) is false.
      Returns:
      if the if the calendar is set to Israel
    • isBirkasHachamah

      public boolean isBirkasHachamah()
      Birkas Hachamah is recited every 28 years based on Tekufas Shmulel (Julian years) that a year is 365.25 days. The Rambam in Hilchos Kiddush Hachodesh 9:3 states that tekufas Nisan of year 1 was 7 days + 9 hours before molad Nisan. This is calculated as every 10,227 days (28 * 365.25).
      Returns:
      true for a day that Birkas Hachamah is recited.
    • getParshaYearType

      private int getParshaYearType()
      Return the type of year for parsha calculations. The algorithm follows the Luach Arba'ah Shearim in the Tur Ohr Hachaim.
      Returns:
      the type of year for parsha calculations.
    • getParshah

      Returns this week's JewishCalendar.Parsha if it is Shabbos. returns Parsha.NONE if a weekday or if there is no parshah that week (for example Yomtov is on Shabbos)
      Returns:
      the current parsha
    • getSpecialShabbos

      Returns a parsha enum if the Shabbos is one of the four parshiyos of Parsha.SHKALIM, Parsha.ZACHOR, Parsha.PARA, Parsha.HACHODESH or Parsha.NONE for a regular Shabbos (or any weekday).
      Returns:
      one of the four parshiyos of Parsha.SHKALIM, Parsha.ZACHOR, Parsha.PARA, Parsha.HACHODESH or Parsha.NONE.
    • getYomTovIndex

      public int getYomTovIndex()
      Returns an index of the Jewish holiday or fast day for the current day, or a -1 if there is no holiday for this day. There are constants in this class representing each Yom Tov. Formatting of the Yomim tovim is done in the ZmanimFormatter#
      Returns:
      the index of the holiday such as the constant LAG_BAOMER or YOM_KIPPUR or a -1 if it is not a holiday.
      See Also:
      HebrewDateFormatter
      TODO:
      consider using enums instead of the constant ints.
    • isYomTov

      public boolean isYomTov()
      Returns true if the current day is Yom Tov. The method returns true even for holidays such as CHANUKAH and minor ones such as TU_BEAV and PESACH_SHENI. Erev Yom Tov (with the exception of HOSHANA_RABBA, Erev the second days of Pesach) returns false, as do fast days besides YOM_KIPPUR. Use isAssurBemelacha() to find the days that have a prohibition of work.
      Returns:
      true if the current day is a Yom Tov
      See Also:
      getYomTovIndex(), isErevYomTov(), isErevYomTovSheni(), isTaanis(), isAssurBemelacha(), isCholHamoed()
    • isYomTovAssurBemelacha

      public boolean isYomTovAssurBemelacha()
      Returns true if the Yom Tov day has a melacha (work) prohibition. This method will return false for a non-Yom Tov day, even if it is Shabbos.
      Returns:
      if the Yom Tov day has a melacha (work) prohibition.
    • isAssurBemelacha

      public boolean isAssurBemelacha()
      Returns true if it is Shabbos or if it is a Yom Tov day that has a melacha (work) prohibition. This method will return false for a.
      Returns:
      if the day is a Yom Tov that is assur bemlacha or Shabbos
    • hasCandleLighting

      public boolean hasCandleLighting()
      Returns true if the day has candle lighting. This will return true on erev Shabbos, erev Yom Tov, the first day of Rosh Hashana and the first days of Yom Tov out of Israel. It is identical to calling isTomorrowShabbosOrYomTov().
      Returns:
      if the day has candle lighting
    • isTomorrowShabbosOrYomTov

      public boolean isTomorrowShabbosOrYomTov()
      Returns true if tomorrow is Shabbos or Yom Tov. This will return true on erev Shabbos, erev Yom Tov, the first day of Rosh Hashana and erev the first days of Yom Tov out of Israel. It is identical to calling hasCandleLighting().
      Returns:
      will return if the next day is Shabbos or Yom Tov
    • isErevYomTovSheni

      public boolean isErevYomTovSheni()
      Returns true if the day is the second day of Yom Tov. This impacts the second day of Rosh Hashana everywhere and the second days of Yom Tov in chutz laaretz (out of Israel).
      Returns:
      if the day is the second day of Yom Tov.
    • isAseresYemeiTeshuva

      public boolean isAseresYemeiTeshuva()
      Returns true if the current day is Aseret Yemei Teshuva.
      Returns:
      if the current day is Aseret Yemei Teshuvah
    • isCholHamoed

      public boolean isCholHamoed()
      Returns true if the current day is Chol Hamoed of Pesach or Succos.
      Returns:
      true if the current day is Chol Hamoed of Pesach or Succos
      See Also:
      isYomTov(), CHOL_HAMOED_PESACH, CHOL_HAMOED_SUCCOS
    • isCholHamoedPesach

      public boolean isCholHamoedPesach()
      Returns true if the current day is Chol Hamoed of Pesach.
      Returns:
      true if the current day is Chol Hamoed of Pesach
      See Also:
      isYomTov(), CHOL_HAMOED_PESACH
    • isCholHamoedSuccos

      public boolean isCholHamoedSuccos()
      Returns true if the current day is Chol Hamoed of Succos.
      Returns:
      true if the current day is Chol Hamoed of Succos
      See Also:
      isYomTov(), CHOL_HAMOED_SUCCOS
    • isErevYomTov

      public boolean isErevYomTov()
      Returns true if the current day is erev Yom Tov. The method returns true for Erev - Pesach (first and last days), Shavuos, Rosh Hashana, Yom Kippur and Succos and Hoshana Rabba.
      Returns:
      true if the current day is Erev - Pesach, Shavuos, Rosh Hashana, Yom Kippur and Succos
      See Also:
      isYomTov(), isErevYomTovSheni()
    • isErevRoshChodesh

      public boolean isErevRoshChodesh()
      Returns true if the current day is Erev Rosh Chodesh. Returns false for Erev Rosh Hashana
      Returns:
      true if the current day is Erev Rosh Chodesh. Returns false for Erev Rosh Hashana
      See Also:
      isRoshChodesh()
    • isTaanis

      public boolean isTaanis()
      Return true if the day is a Taanis (fast day). Return true for 17 of Tammuz, Tisha B'Av, Yom Kippur, Fast of Gedalyah, 10 of Teves and the Fast of Esther
      Returns:
      true if today is a fast day
    • getDayOfChanukah

      public int getDayOfChanukah()
      Returns the day of Chanukah or -1 if it is not Chanukah.
      Returns:
      the day of Chanukah or -1 if it is not Chanukah.
      See Also:
      isChanukah()
    • isChanukah

      public boolean isChanukah()
      Returns true if the current day is one of the 8 days of Chanukah.
      Returns:
      if the current day is one of the 8 days of Chanukah.
      See Also:
      getDayOfChanukah()
    • isRoshChodesh

      public boolean isRoshChodesh()
      Returns if the day is Rosh Chodesh. Rosh Hashana will return false
      Returns:
      true if it is Rosh Chodesh. Rosh Hashana will return false
    • isMacharChodesh

      public boolean isMacharChodesh()
      Returns if the day is Shabbos and sunday is Rosh Chodesh.
      Returns:
      true if it is Shabbos and sunday is Rosh Chodesh.
    • isShabbosMevorchim

      public boolean isShabbosMevorchim()
      Returns if the day is Shabbos Mevorchim.
      Returns:
      true if it is Shabbos Mevorchim.
    • getDayOfOmer

      public int getDayOfOmer()
      Returns the int value of the Omer day or -1 if the day is not in the omer
      Returns:
      The Omer count as an int or -1 if it is not a day of the Omer.
    • getMoladAsDate

      public Date getMoladAsDate()
      Returns the molad in Standard Time in Yerushalayim as a Date. The traditional calculation uses local time. This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the local time (Har Habayis with a longitude of 35.2354° is 5.2354° away from the %15 timezone longitude) to get to standard time. This method intentionally uses standard time and not dailight savings time. Java will implicitly format the time to the default (or set) Timezone.
      Returns:
      the Date representing the moment of the molad in Yerushalayim standard time (GMT + 2)
    • getTchilasZmanKidushLevana3Days

      Returns the earliest time of Kiddush Levana calculated as 3 days after the molad. This method returns the time even if it is during the day when Kiddush Levana can't be said. Callers of this method should consider displaying the next tzais if the zman is between alos and tzais.
      Returns:
      the Date representing the moment 3 days after the molad.
      See Also:
      ComplexZmanimCalendar.getTchilasZmanKidushLevana3Days(), ComplexZmanimCalendar.getTchilasZmanKidushLevana3Days(Date, Date)
    • getTchilasZmanKidushLevana7Days

      Returns the earliest time of Kiddush Levana calculated as 7 days after the molad as mentioned by the Mechaber. See the Bach's opinion on this time. This method returns the time even if it is during the day when Kiddush Levana can't be said. Callers of this method should consider displaying the next tzais if the zman is between alos and tzais.
      Returns:
      the Date representing the moment 7 days after the molad.
      See Also:
      ComplexZmanimCalendar.getTchilasZmanKidushLevana7Days(), ComplexZmanimCalendar.getTchilasZmanKidushLevana7Days(Date, Date)
    • getSofZmanKidushLevanaBetweenMoldos

      Returns the latest time of Kiddush Levana according to the Maharil's opinion that it is calculated as halfway between molad and molad. This adds half the 29 days, 12 hours and 793 chalakim time between molad and molad (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's molad. This method returns the time even if it is during the day when Kiddush Levana can't be said. Callers of this method should consider displaying alos before this time if the zman is between alos and tzais.
      Returns:
      the Date representing the moment halfway between molad and molad.
      See Also:
      getSofZmanKidushLevana15Days(), ComplexZmanimCalendar.getSofZmanKidushLevanaBetweenMoldos(), ComplexZmanimCalendar.getSofZmanKidushLevanaBetweenMoldos(Date, Date)
    • getSofZmanKidushLevana15Days

      Returns the latest time of Kiddush Levana calculated as 15 days after the molad. This is the opinion brought down in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the Rema who brings down the opinion of the Maharil's of calculating half way between molad and mold is of the opinion that Mechaber agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject, See Rabbi Dovid Heber's very detailed writeup in Siman Daled (chapter 4) of Shaarei Zmanim. This method returns the time even if it is during the day when Kiddush Levana can't be said. Callers of this method should consider displaying alos before this time if the zman is between alos and tzais.
      Returns:
      the Date representing the moment 15 days after the molad.
      See Also:
      getSofZmanKidushLevanaBetweenMoldos(), ComplexZmanimCalendar.getSofZmanKidushLevana15Days(), ComplexZmanimCalendar.getSofZmanKidushLevana15Days(Date, Date)
    • getDafYomiBavli

      public Daf getDafYomiBavli()
      Returns the Daf Yomi (Bavli) for the date that the calendar is set to. See the HebrewDateFormatter.formatDafYomiBavli(Daf) for the ability to format the daf in Hebrew or transliterated masechta names.
      Returns:
      the daf as a Daf
    • getDafYomiYerushalmi

      Returns the Daf Yomi (Yerushalmi) for the date that the calendar is set to. See the HebrewDateFormatter.formatDafYomiYerushalmi(Daf) for the ability to format the daf in Hebrew or transliterated masechta names.
      Returns:
      the daf as a Daf
    • equals

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

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