001/* 002 * Zmanim Java API 003 * Copyright (C) 2011 - 2023 Eliyahu Hershfeld 004 * Copyright (C) September 2002 Avrom Finkelstien 005 * Copyright (C) 2019 - 2022 Y Paritcher 006 * 007 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General 008 * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) 009 * any later version. 010 * 011 * This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied 012 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 013 * details. 014 * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to 015 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, 016 * or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html 017 */ 018package com.kosherjava.zmanim.hebrewcalendar; 019 020import com.kosherjava.zmanim.util.GeoLocation; 021 022import java.time.LocalDate; 023import java.util.Calendar; 024import java.util.Date; 025import java.util.TimeZone; 026 027/** 028 * The JewishCalendar extends the JewishDate class and adds calendar methods. 029 * 030 * This open source Java code was originally ported by <a href="http://www.facebook.com/avromf">Avrom Finkelstien</a> 031 * from his C++ code. It was refactored to fit the KosherJava Zmanim API with simplification of the code, enhancements 032 * and some bug fixing. The class allows setting whether the holiday and <em>parsha</em> scheme follows the Israel scheme 033 * or outside Israel scheme. The default is the outside Israel scheme. 034 * The parsha code was ported by Y. Paritcher from his <a href="https://github.com/yparitcher/libzmanim">libzmanim</a> code. 035 * 036 * @todo Some do not belong in this class, but here is a partial list of what should still be implemented in some form: 037 * <ol> 038 * <li>Mishna yomis etc</li> 039 * </ol> 040 * 041 * @see java.util.Date 042 * @see java.util.Calendar 043 * @author © Y. Paritcher 2019 - 2022 044 * @author © Avrom Finkelstien 2002 045 * @author © Eliyahu Hershfeld 2011 - 2023 046 */ 047public class JewishCalendar extends JewishDate { 048 /** The 14th day of Nissan, the day before of Pesach (Passover).*/ 049 public static final int EREV_PESACH = 0; 050 /** The holiday of Pesach (Passover) on the 15th (and 16th out of Israel) day of Nissan.*/ 051 public static final int PESACH = 1; 052 /** Chol Hamoed (interim days) of Pesach (Passover)*/ 053 public static final int CHOL_HAMOED_PESACH = 2; 054 /**Pesach Sheni, the 14th day of Iyar, a minor holiday.*/ 055 public static final int PESACH_SHENI = 3; 056 /**Erev Shavuos (the day before Shavuos), the 5th of Sivan*/ 057 public static final int EREV_SHAVUOS = 4; 058 /**Shavuos (Pentecost), the 6th of Sivan*/ 059 public static final int SHAVUOS = 5; 060 /** The fast of the 17th day of Tamuz*/ 061 public static final int SEVENTEEN_OF_TAMMUZ = 6; 062 /** The fast of the 9th of Av*/ 063 public static final int TISHA_BEAV = 7; 064 /** The 15th day of Av, a minor holiday*/ 065 public static final int TU_BEAV = 8; 066 /**Erev Rosh Hashana (the day before Rosh Hashana), the 29th of Elul*/ 067 public static final int EREV_ROSH_HASHANA = 9; 068 /** Rosh Hashana, the first of Tishrei.*/ 069 public static final int ROSH_HASHANA = 10; 070 /** The fast of Gedalyah, the 3rd of Tishrei.*/ 071 public static final int FAST_OF_GEDALYAH = 11; 072 /** The 9th day of Tishrei, the day before of Yom Kippur.*/ 073 public static final int EREV_YOM_KIPPUR = 12; 074 /** The holiday of Yom Kippur, the 10th day of Tishrei*/ 075 public static final int YOM_KIPPUR = 13; 076 /** The 14th day of Tishrei, the day before of Succos/Sukkos (Tabernacles).*/ 077 public static final int EREV_SUCCOS = 14; 078 /** The holiday of Succos/Sukkos (Tabernacles), the 15th (and 16th out of Israel) day of Tishrei */ 079 public static final int SUCCOS = 15; 080 /** Chol Hamoed (interim days) of Succos/Sukkos (Tabernacles)*/ 081 public static final int CHOL_HAMOED_SUCCOS = 16; 082 /** Hoshana Rabba, the 7th day of Succos/Sukkos that occurs on the 21st of Tishrei. */ 083 public static final int HOSHANA_RABBA = 17; 084 /** Shmini Atzeres, the 8th day of Succos/Sukkos is an independent holiday that occurs on the 22nd of Tishrei. */ 085 public static final int SHEMINI_ATZERES = 18; 086 /** Simchas Torah, the 9th day of Succos/Sukkos, or the second day of Shmini Atzeres that is celebrated 087 * {@link #getInIsrael() out of Israel} on the 23rd of Tishrei. 088 */ 089 public static final int SIMCHAS_TORAH = 19; 090 // public static final int EREV_CHANUKAH = 20;// probably remove this 091 /** The holiday of Chanukah. 8 days starting on the 25th day Kislev.*/ 092 public static final int CHANUKAH = 21; 093 /** The fast of the 10th day of Teves.*/ 094 public static final int TENTH_OF_TEVES = 22; 095 /** Tu Bishvat on the 15th day of Shevat, a minor holiday.*/ 096 public static final int TU_BESHVAT = 23; 097 /** The fast of Esther, usually on the 13th day of Adar (or Adar II on leap years). It is earlier on some years.*/ 098 public static final int FAST_OF_ESTHER = 24; 099 /** The holiday of Purim on the 14th day of Adar (or Adar II on leap years).*/ 100 public static final int PURIM = 25; 101 /** The holiday of Shushan Purim on the 15th day of Adar (or Adar II on leap years).*/ 102 public static final int SHUSHAN_PURIM = 26; 103 /** The holiday of Purim Katan on the 14th day of Adar I on a leap year when Purim is on Adar II, a minor holiday.*/ 104 public static final int PURIM_KATAN = 27; 105 /** 106 * Rosh Chodesh, the new moon on the first day of the Jewish month, and the 30th day of the previous month in the 107 * case of a month with 30 days. 108 */ 109 public static final int ROSH_CHODESH = 28; 110 /** Yom HaShoah, Holocaust Remembrance Day, usually held on the 27th of Nissan. If it falls on a Friday, it is moved 111 * to the 26th, and if it falls on a Sunday it is moved to the 28th. A {@link #isUseModernHolidays() modern holiday}. 112 */ 113 public static final int YOM_HASHOAH = 29; 114 /** 115 * Yom HaZikaron, Israeli Memorial Day, held a day before Yom Ha'atzmaut. A {@link #isUseModernHolidays() modern holiday}. 116 */ 117 public static final int YOM_HAZIKARON = 30; 118 119 /** Yom Ha'atzmaut, Israel Independence Day, the 5th of Iyar, but if it occurs on a Friday or Saturday, the holiday is 120 * moved back to Thursday, the 3rd of 4th of Iyar, and if it falls on a Monday, it is moved forward to Tuesday the 121 * 6th of Iyar. A {@link #isUseModernHolidays() modern holiday}.*/ 122 public static final int YOM_HAATZMAUT = 31; 123 /** 124 * Yom Yerushalayim or Jerusalem Day, on 28 Iyar. A {@link #isUseModernHolidays() modern holiday}. 125 */ 126 public static final int YOM_YERUSHALAYIM = 32; 127 128 /** The 33rd day of the Omer, the 18th of Iyar, a minor holiday.*/ 129 public static final int LAG_BAOMER = 33; 130 131 /** The holiday of Purim Katan on the 15th day of Adar I on a leap year when Purim is on Adar II, a minor holiday.*/ 132 public static final int SHUSHAN_PURIM_KATAN = 34; 133 134 /** The day following the last day of Pesach, Shavuos and Sukkos.*/ 135 public static final int ISRU_CHAG = 35; 136 137 /** 138 * The day before <em>Rosh Chodesh</em> (moved to Thursday if <em>Rosh Chodesh</em> is on a Friday or <em>Shabbos</em>) in most months. 139 * This constant is not actively in use. 140 * @see #isYomKippurKatan() 141 */ 142 public static final int YOM_KIPPUR_KATAN = 36; 143 144 /** 145 * The Monday, Thursday and Monday after the first <em>Shabbos</em> after <em>Rosh Chodesh Cheshvan</em> and <em>Iyar</em>) are BeHab 146 * days. This constant is not actively in use. 147 * @see #isBeHaB() 148 */ 149 public static final int BEHAB = 37; 150 151 /** 152 * Is the calendar set to Israel, where some holidays have different rules. 153 * @see #getInIsrael() 154 * @see #setInIsrael(boolean) 155 */ 156 private boolean inIsrael = false; 157 158 /** 159 * Is the calendar set to have Purim <em>demukafim</em>, where Purim is celebrated on Shushan Purim. 160 * @see #getIsMukafChoma() 161 * @see #setIsMukafChoma(boolean) 162 */ 163 private boolean isMukafChoma = false; 164 165 /** 166 * Is the calendar set to use modern Israeli holidays such as Yom Haatzmaut. 167 * @see #isUseModernHolidays() 168 * @see #setUseModernHolidays(boolean) 169 */ 170 private boolean useModernHolidays = false; 171 172 /** 173 * List of <em>parshiyos</em> or special <em>Shabasos</em>. {@link #NONE} indicates a week without a <em>parsha</em>, while the enum for 174 * the <em>parsha</em> of {@link #VZOS_HABERACHA} exists for consistency, but is not currently used. The special <em>Shabasos</em> of 175 * Shekalim, Zachor, Para, Hachodesh, as well as Shabbos Shuva, Shira, Hagadol, Chazon and Nachamu are also represented in this collection 176 * of <em>parshiyos</em>. 177 * @see #getSpecialShabbos() 178 * @see #getParshah() 179 */ 180 public static enum Parsha { 181 /**NONE A week without any <em>parsha</em> such as <em>Shabbos Chol Hamoed</em> */NONE, 182 /**BERESHIS*/BERESHIS, /**NOACH*/NOACH, /**LECH_LECHA*/LECH_LECHA, /**VAYERA*/VAYERA, /**CHAYEI_SARA*/CHAYEI_SARA, /**TOLDOS*/TOLDOS, 183 /**VAYETZEI*/VAYETZEI, /**VAYISHLACH*/VAYISHLACH, /**VAYESHEV*/VAYESHEV, /**MIKETZ*/MIKETZ, /**VAYIGASH*/VAYIGASH, /**VAYECHI*/VAYECHI, 184 /**SHEMOS*/SHEMOS, /**VAERA*/VAERA, /**BO*/BO, /**BESHALACH*/BESHALACH, /**YISRO*/YISRO, /**MISHPATIM*/MISHPATIM, /**TERUMAH*/TERUMAH, 185 /**TETZAVEH*/TETZAVEH, /***KI_SISA*/KI_SISA, /**VAYAKHEL*/VAYAKHEL, /**PEKUDEI*/PEKUDEI, /**VAYIKRA*/VAYIKRA, /**TZAV*/TZAV, /**SHMINI*/SHMINI, 186 /**TAZRIA*/TAZRIA, /**METZORA*/METZORA, /**ACHREI_MOS*/ACHREI_MOS, /**KEDOSHIM*/KEDOSHIM, /**EMOR*/EMOR, /**BEHAR*/BEHAR, /**BECHUKOSAI*/BECHUKOSAI, 187 /**BAMIDBAR*/BAMIDBAR, /**NASSO*/NASSO, /**BEHAALOSCHA*/BEHAALOSCHA, /**SHLACH*/SHLACH, /**KORACH*/KORACH, /**CHUKAS*/CHUKAS, /**BALAK*/BALAK, 188 /**PINCHAS*/PINCHAS, /**MATOS*/MATOS, /**MASEI*/MASEI, /**DEVARIM*/DEVARIM, /**VAESCHANAN*/VAESCHANAN, /**EIKEV*/EIKEV, /**REEH*/REEH, 189 /**SHOFTIM*/SHOFTIM, /**KI_SEITZEI*/KI_SEITZEI, /**KI_SAVO*/KI_SAVO, /**NITZAVIM*/NITZAVIM, /**VAYEILECH*/VAYEILECH, /**HAAZINU*/HAAZINU, 190 /**VZOS_HABERACHA*/VZOS_HABERACHA, /**The double parsha of Vayakhel & Peudei*/VAYAKHEL_PEKUDEI, /**The double <em>parsha</em> of Tazria 191 * & Metzora*/TAZRIA_METZORA,/**The double <em>parsha</em> of Achrei Mos & Kedoshim*/ACHREI_MOS_KEDOSHIM,/**The double <em>parsha</em> 192 * of Behar & Bechukosai*/BEHAR_BECHUKOSAI,/**The double <em>parsha</em> of Chukas & Balak*/CHUKAS_BALAK, /**The double 193 * <em>parsha</em> of Matos & Masei*/MATOS_MASEI,/**The double <em>parsha</em> of Nitzavim & Vayelech*/NITZAVIM_VAYEILECH, 194 /**The special <em>parsha</em> of Shekalim*/SHKALIM, /** The special <em>parsha</em> of Zachor*/ZACHOR, /**The special <em>parsha</em> of 195 * Para*/PARA, /** The special <em>parsha</em> of Hachodesh*/HACHODESH, /**<em>Shabbos</em> Shuva*/SHUVA, /**<em>Shabbos</em> Shira*/SHIRA, 196 /**<em>Shabbos</em> Hagadol*/HAGADOL, /**<em>Shabbos</em> Chazon*/CHAZON, /**<em>Shabbos</em> Nachamu*/NACHAMU 197 }; 198 199 /** 200 * An array of <em>parshiyos</em> in the 17 possible combinations. 201 */ 202 public static final Parsha[][] parshalist = { 203 {Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 204 {Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NONE, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS_BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 205 {Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM}, 206 {Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM}, 207 {Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM}, 208 {Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 209 {Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NONE, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS_BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 210 {Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM}, 211 {Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.ACHREI_MOS, Parsha.NONE, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS, Parsha.MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM}, 212 {Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.ACHREI_MOS, Parsha.NONE, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS, Parsha.MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 213 {Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 214 {Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NONE, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS_BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 215 {Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 216 {Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM}, 217 {Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH}, 218 {Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS, Parsha.MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM}, 219 {Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH} 220 }; 221 222 /** 223 * Is this calendar set to return modern Israeli national holidays. By default this value is false. The holidays 224 * are {@link #YOM_HASHOAH <em>Yom HaShoah</em>}, {@link #YOM_HAZIKARON <em>Yom Hazikaron</em>}, {@link 225 * #YOM_HAATZMAUT <em>Yom Ha'atzmaut</em>} and {@link #YOM_YERUSHALAYIM <em>Yom Yerushalayim</em>}. 226 * 227 * @return the useModernHolidays true if set to return modern Israeli national holidays 228 * 229 * @see #setUseModernHolidays(boolean) 230 */ 231 public boolean isUseModernHolidays() { 232 return useModernHolidays; 233 } 234 235 /** 236 * Sets the calendar to return modern Israeli national holidays. By default this value is false. The holidays are: 237 * {@link #YOM_HASHOAH <em>Yom HaShoah</em>}, {@link #YOM_HAZIKARON <em>Yom Hazikaron</em>}, {@link 238 * #YOM_HAATZMAUT <em>Yom Ha'atzmaut</em>} and {@link #YOM_YERUSHALAYIM <em>Yom Yerushalayim</em>}. 239 * 240 * @param useModernHolidays 241 * the useModernHolidays to set 242 * 243 * @see #isUseModernHolidays() 244 */ 245 public void setUseModernHolidays(boolean useModernHolidays) { 246 this.useModernHolidays = useModernHolidays; 247 } 248 249 /** 250 * Default constructor will set a default date to the current system date. 251 */ 252 public JewishCalendar() { 253 super(); 254 } 255 256 /** 257 * A constructor that initializes the date to the {@link java.util.Date Date} parameter. 258 * 259 * @param date 260 * the <code>Date</code> to set the calendar to 261 */ 262 public JewishCalendar(Date date) { 263 super(date); 264 } 265 266 /** 267 * A constructor that initializes the date to the {@link java.util.Calendar Calendar} parameter. 268 * 269 * @param calendar 270 * the <code>Calendar</code> to set the calendar to 271 */ 272 public JewishCalendar(Calendar calendar) { 273 super(calendar); 274 } 275 276 /** 277 * A constructor that initializes the date to the {@link java.time.LocalDate LocalDate} parameter. 278 * 279 * @param localDate 280 * the <code>LocalDate</code> to set the calendar to 281 */ 282 public JewishCalendar(LocalDate localDate) { 283 super(localDate); 284 } 285 286 /** 287 * Creates a Jewish date based on a Jewish year, month and day of month. 288 * 289 * @param jewishYear 290 * the Jewish year 291 * @param jewishMonth 292 * the Jewish month. The method expects a 1 for Nissan ... 12 for Adar and 13 for Adar II. Use the 293 * constants {@link #NISSAN} ... {@link #ADAR} (or {@link #ADAR_II} for a leap year Adar II) to avoid any 294 * confusion. 295 * @param jewishDayOfMonth 296 * the Jewish day of month. If 30 is passed in for a month with only 29 days (for example {@link #IYAR}, 297 * or {@link #KISLEV} in a year that {@link #isKislevShort()}), the 29th (last valid date of the month) 298 * will be set 299 * @throws IllegalArgumentException 300 * if the day of month is < 1 or > 30, or a year of < 0 is passed in. 301 */ 302 public JewishCalendar(int jewishYear, int jewishMonth, int jewishDayOfMonth) { 303 super(jewishYear, jewishMonth, jewishDayOfMonth); 304 } 305 306 /** 307 * Creates a Jewish date based on a Jewish date and whether in Israel 308 * 309 * @param jewishYear 310 * the Jewish year 311 * @param jewishMonth 312 * the Jewish month. The method expects a 1 for <em>Nissan</em> ... 12 for <em>Adar</em> and 13 for 313 * <em>Adar II</em>. Use the constants {@link #NISSAN} ... {@link #ADAR} (or {@link #ADAR_II} for a 314 * leap year Adar II) to avoid any confusion. 315 * @param jewishDayOfMonth 316 * the Jewish day of month. If 30 is passed in for a month with only 29 days (for example {@link #IYAR}, 317 * or {@link #KISLEV} in a year that {@link #isKislevShort()}), the 29th (last valid date of the month) 318 * will be set. 319 * @param inIsrael 320 * whether in Israel. This affects <em>Yom Tov</em> calculations 321 */ 322 public JewishCalendar(int jewishYear, int jewishMonth, int jewishDayOfMonth, boolean inIsrael) { 323 super(jewishYear, jewishMonth, jewishDayOfMonth); 324 setInIsrael(inIsrael); 325 } 326 327 /** 328 * Sets whether to use Israel holiday scheme or not. Default is false. 329 * 330 * @param inIsrael 331 * set to true for calculations for Israel 332 * 333 * @see #getInIsrael() 334 */ 335 public void setInIsrael(boolean inIsrael) { 336 this.inIsrael = inIsrael; 337 } 338 339 /** 340 * Gets whether Israel holiday scheme is used or not. The default (if not set) is false. 341 * 342 * @return if the calendar is set to Israel 343 * 344 * @see #setInIsrael(boolean) 345 */ 346 public boolean getInIsrael() { 347 return inIsrael; 348 } 349 350 /** 351 * Returns if the city is set as a city surrounded by a wall from the time of Yehoshua, and Shushan Purim 352 * should be celebrated as opposed to regular Purim. 353 * @return if the city is set as a city surrounded by a wall from the time of Yehoshua, and Shushan Purim 354 * should be celebrated as opposed to regular Purim. 355 * @see #setIsMukafChoma(boolean) 356 */ 357 public boolean getIsMukafChoma() { 358 return isMukafChoma; 359 } 360 361 /** 362 * Sets if the location is surrounded by a wall from the time of Yehoshua, and Shushan Purim should be 363 * celebrated as opposed to regular Purim. This should be set for Yerushalayim, Shushan and other cities. 364 * @param isMukafChoma is the city surrounded by a wall from the time of Yehoshua. 365 * 366 * @see #getIsMukafChoma() 367 */ 368 public void setIsMukafChoma(boolean isMukafChoma) { 369 this.isMukafChoma = isMukafChoma; 370 } 371 372 /** 373 * <a href="https://en.wikipedia.org/wiki/Birkat_Hachama">Birkas Hachamah</a> is recited every 28 years based on 374 * <em>Tekufas Shmuel</em> (Julian years) that a year is 365.25 days. The <a href="https://en.wikipedia.org/wiki/Maimonides" 375 * >Rambam</a> in <a href="http://hebrewbooks.org/pdfpager.aspx?req=14278&st=&pgnum=323">Hilchos Kiddush Hachodesh 9:3</a> 376 * states that <em>tekufas Nissan</em> of year 1 was 7 days + 9 hours before <em>molad Nissan</em>. This is calculated as every 377 * 10,227 days (28 * 365.25). 378 * @return true for a day that <em>Birkas Hachamah</em> is recited. 379 */ 380 public boolean isBirkasHachamah() { 381 int elapsedDays = getJewishCalendarElapsedDays(getJewishYear()); //elapsed days since molad ToHu 382 elapsedDays = elapsedDays + getDaysSinceStartOfJewishYear(); //elapsed days to the current calendar date 383 384 /* Molad Nissan year 1 was 177 days after molad tohu of Tishrei. We multiply 29.5 days * 6 months from Tishrei 385 * to Nissan = 177. Subtract 7 days since tekufas Nissan was 7 days and 9 hours before the molad as stated in the Rambam 386 * and we are now at 170 days. Because getJewishCalendarElapsedDays and getDaysSinceStartOfJewishYear use the value for 387 * Rosh Hashana as 1, we have to add 1 day for a total of 171. To this add a day since the tekufah is on a Tuesday 388 * night and we push off the bracha to Wednesday AM resulting in the 172 used in the calculation. 389 */ 390 if (elapsedDays % (28 * 365.25) == 172) { // 28 years of 365.25 days + the offset from molad tohu mentioned above 391 return true; 392 } 393 return false; 394 } 395 396 /** 397 * Return the type of year for <em>parsha</em> calculations. The algorithm follows the 398 * <a href="http://hebrewbooks.org/pdfpager.aspx?req=14268&st=&pgnum=222">Luach Arba'ah Shearim</a> in the Tur Ohr Hachaim. 399 * @return the type of year for <em>parsha</em> calculations. 400 */ 401 private int getParshaYearType() { 402 int roshHashanaDayOfWeek = (getJewishCalendarElapsedDays(getJewishYear()) + 1) % 7; // plus one to the original Rosh Hashana of year 1 to get a week starting on Sunday 403 if (roshHashanaDayOfWeek == 0) { 404 roshHashanaDayOfWeek = 7; // convert 0 to 7 for Shabbos for readability 405 } 406 if (isJewishLeapYear()) { 407 switch (roshHashanaDayOfWeek) { 408 case Calendar.MONDAY: 409 if (isKislevShort()) { //BaCh 410 if (getInIsrael()) { 411 return 14; 412 } 413 return 6; 414 } 415 if (isCheshvanLong()) { //BaSh 416 if (getInIsrael()) { 417 return 15; 418 } 419 return 7; 420 } 421 break; 422 case Calendar.TUESDAY: //Gak 423 if (getInIsrael()) { 424 return 15; 425 } 426 return 7; 427 case Calendar.THURSDAY: 428 if (isKislevShort()) { //HaCh 429 return 8; 430 } 431 if (isCheshvanLong()) { //HaSh 432 return 9; 433 } 434 break; 435 case Calendar.SATURDAY: 436 if (isKislevShort()) { //ZaCh 437 return 10; 438 } 439 if (isCheshvanLong()) { //ZaSh 440 if (getInIsrael()) { 441 return 16; 442 } 443 return 11; 444 } 445 break; 446 } 447 } else { //not a leap year 448 switch (roshHashanaDayOfWeek) { 449 case Calendar.MONDAY: 450 if (isKislevShort()) { //BaCh 451 return 0; 452 } 453 if (isCheshvanLong()) { //BaSh 454 if (getInIsrael()) { 455 return 12; 456 } 457 return 1; 458 } 459 break; 460 case Calendar.TUESDAY: //GaK 461 if (getInIsrael()) { 462 return 12; 463 } 464 return 1; 465 case Calendar.THURSDAY: 466 if (isCheshvanLong()) { //HaSh 467 return 3; 468 } 469 if (!isKislevShort()) { //Hak 470 if (getInIsrael()) { 471 return 13; 472 } 473 return 2; 474 } 475 break; 476 case Calendar.SATURDAY: 477 if (isKislevShort()) { //ZaCh 478 return 4; 479 } 480 if (isCheshvanLong()) { //ZaSh 481 return 5; 482 } 483 break; 484 } 485 } 486 return -1; //keep the compiler happy 487 } 488 489 /** 490 * Returns this week's {@link Parsha <em>Parsha</em>} if it is <em>Shabbos</em>. It returns {@link Parsha#NONE} if the date 491 * is a weekday or if there is no <em>parsha</em> that week (for example <em>Yom Tov</em> that falls on a <em>Shabbos</em>). 492 * 493 * @return the current <em>parsha</em>. 494 */ 495 public Parsha getParshah() { 496 if (getDayOfWeek() != Calendar.SATURDAY) { 497 return Parsha.NONE; 498 } 499 500 int yearType = getParshaYearType(); 501 int roshHashanaDayOfWeek = getJewishCalendarElapsedDays(getJewishYear()) % 7; 502 int day = roshHashanaDayOfWeek + getDaysSinceStartOfJewishYear(); 503 504 if (yearType >= 0) { // negative year should be impossible, but let's cover all bases 505 return parshalist[yearType][day/7]; 506 } 507 return Parsha.NONE; //keep the compiler happy 508 } 509 510 /** 511 * Returns the upcoming {@link Parsha <em>Parsha</em>} regardless of if it is the weekday or <em>Shabbos</em> (where next 512 * Shabbos's <em>Parsha</em> will be returned. This is unlike {@link #getParshah()} that returns {@link Parsha#NONE} if 513 * the date is not <em>Shabbos</em>. If the upcoming <em>Shabbos</em> is a <em>Yom Tov</em> and has no <em>Parsha</em>, the 514 * following week's <em>Parsha</em> will be returned. 515 * 516 * @return the upcoming <em>parsha</em>. 517 */ 518 public Parsha getUpcomingParshah() { 519 JewishCalendar clone = (JewishCalendar) clone(); 520 int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7; 521 if (getDayOfWeek() != Calendar.SATURDAY) { 522 clone.forward(Calendar.DATE, daysToShabbos); 523 } else { 524 clone.forward(Calendar.DATE, 7); 525 } 526 while(clone.getParshah() == Parsha.NONE) { //Yom Kippur / Sukkos or Pesach with 2 potential non-parsha Shabbosim in a row 527 clone.forward(Calendar.DATE, 7); 528 } 529 return clone.getParshah(); 530 } 531 532 /** 533 * Returns a {@link Parsha <em>Parsha</em>} enum if the <em>Shabbos</em> is one of the four <em>parshiyos</em> of {@link 534 * Parsha#SHKALIM <em>Shkalim</em>}, {@link Parsha#ZACHOR <em>Zachor</em>}, {@link Parsha#PARA <em>Para</em>}, {@link 535 * Parsha#HACHODESH <em>Hachdesh</em>}, or five other special <em>Shabbasos</em> of {@link Parsha#HAGADOL <em>Hagadol</em>}, 536 * {@link Parsha#CHAZON <em>Chazon</em>}, {@link Parsha#NACHAMU <em>Nachamu</em>}, {@link Parsha#SHUVA <em>Shuva</em>}, 537 * {@link Parsha#SHIRA <em>Shira</em>}, or {@link Parsha#NONE Parsha.NONE} for a regular <em>Shabbos</em> (or any weekday). 538 * 539 * @return one of the four <em>parshiyos</em> of {@link Parsha#SHKALIM <em>Shkalim</em>}, {@link Parsha#ZACHOR <em>Zachor</em>}, 540 * {@link Parsha#PARA <em>Para</em>}, {@link Parsha#HACHODESH <em>Hachdesh</em>}, or five other special <em>Shabbasos</em> 541 * of {@link Parsha#HAGADOL <em>Hagadol</em>}, {@link Parsha#CHAZON <em>Chazon</em>}, {@link Parsha#NACHAMU <em>Nachamu</em>}, 542 * {@link Parsha#SHUVA <em>Shuva</em>}, {@link Parsha#SHIRA <em>Shira</em>}, or {@link Parsha#NONE Parsha.NONE} for a regular 543 * <em>Shabbos</em> (or any weekday). 544 */ 545 public Parsha getSpecialShabbos() { 546 if (getDayOfWeek() == Calendar.SATURDAY) { 547 if ((getJewishMonth() == SHEVAT && !isJewishLeapYear()) || (getJewishMonth() == ADAR && isJewishLeapYear())) { 548 if (getJewishDayOfMonth() == 25 || getJewishDayOfMonth() == 27 || getJewishDayOfMonth() == 29) { 549 return Parsha.SHKALIM; 550 } 551 } 552 if ((getJewishMonth() == ADAR && !isJewishLeapYear()) || getJewishMonth() == ADAR_II) { 553 if (getJewishDayOfMonth() == 1) { 554 return Parsha.SHKALIM; 555 } 556 if (getJewishDayOfMonth() == 8 || getJewishDayOfMonth() == 9 || getJewishDayOfMonth() == 11 || getJewishDayOfMonth() == 13) { 557 return Parsha.ZACHOR; 558 } 559 if (getJewishDayOfMonth() == 18 || getJewishDayOfMonth() == 20 || getJewishDayOfMonth() == 22 || getJewishDayOfMonth() == 23) { 560 return Parsha.PARA; 561 } 562 if (getJewishDayOfMonth() == 25 || getJewishDayOfMonth() == 27 || getJewishDayOfMonth() == 29) { 563 return Parsha.HACHODESH; 564 } 565 } 566 if (getJewishMonth() == NISSAN) { 567 if(getJewishDayOfMonth() == 1) { 568 return Parsha.HACHODESH; 569 } 570 if(getJewishDayOfMonth() >= 8 && getJewishDayOfMonth() <= 14) { 571 return Parsha.HAGADOL; 572 } 573 } 574 if (getJewishMonth() == AV) { 575 if(getJewishDayOfMonth() >= 4 && getJewishDayOfMonth() <= 9) { 576 return Parsha.CHAZON; 577 } 578 if(getJewishDayOfMonth() >= 10 && getJewishDayOfMonth() <= 16) { 579 return Parsha.NACHAMU; 580 } 581 } 582 if (getJewishMonth() == TISHREI) { 583 if(getJewishDayOfMonth() >= 3 && getJewishDayOfMonth() <= 8) { 584 return Parsha.SHUVA; 585 } 586 587 } 588 if(getParshah() == Parsha.BESHALACH) { 589 return Parsha.SHIRA; 590 } 591 } 592 return Parsha.NONE; 593 } 594 595 /** 596 * 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. 597 * There are constants in this class representing each <em>Yom Tov</em>. Formatting of the <em>Yomim tovim</em> is done 598 * in the {@link HebrewDateFormatter#formatYomTov(JewishCalendar)}. 599 * 600 * @todo Consider using enums instead of the constant ints. 601 * 602 * @return the index of the holiday such as the constant {@link #LAG_BAOMER} or {@link #YOM_KIPPUR} or a -1 if it is not a holiday. 603 * 604 * @see HebrewDateFormatter#formatYomTov(JewishCalendar) 605 */ 606 public int getYomTovIndex() { 607 final int day = getJewishDayOfMonth(); 608 final int dayOfWeek = getDayOfWeek(); 609 610 // check by month (starting from Nissan) 611 switch (getJewishMonth()) { 612 case NISSAN: 613 if (day == 14) { 614 return EREV_PESACH; 615 } 616 if (day == 15 || day == 21 617 || (!inIsrael && (day == 16 || day == 22))) { 618 return PESACH; 619 } 620 if (day >= 17 && day <= 20 621 || (day == 16 && inIsrael)) { 622 return CHOL_HAMOED_PESACH; 623 } 624 if ((day == 22 && inIsrael) || (day == 23 && !inIsrael)) { 625 return ISRU_CHAG; 626 } 627 if (isUseModernHolidays() 628 && ((day == 26 && dayOfWeek == Calendar.THURSDAY) 629 || (day == 28 && dayOfWeek == Calendar.MONDAY) 630 || (day == 27 && dayOfWeek != Calendar.SUNDAY && dayOfWeek != Calendar.FRIDAY))) { 631 return YOM_HASHOAH; 632 } 633 break; 634 case IYAR: 635 if (isUseModernHolidays() 636 && ((day == 4 && dayOfWeek == Calendar.TUESDAY) 637 || ((day == 3 || day == 2) && dayOfWeek == Calendar.WEDNESDAY) || (day == 5 && dayOfWeek == Calendar.MONDAY))) { 638 return YOM_HAZIKARON; 639 } 640 // if 5 Iyar falls on Wed, Yom Haatzmaut is that day. If it fal1s on Friday or Shabbos, it is moved back to 641 // Thursday. If it falls on Monday it is moved to Tuesday 642 if (isUseModernHolidays() 643 && ((day == 5 && dayOfWeek == Calendar.WEDNESDAY) 644 || ((day == 4 || day == 3) && dayOfWeek == Calendar.THURSDAY) || (day == 6 && dayOfWeek == Calendar.TUESDAY))) { 645 return YOM_HAATZMAUT; 646 } 647 if (day == 14) { 648 return PESACH_SHENI; 649 } 650 if (day == 18) { 651 return LAG_BAOMER; 652 } 653 if (isUseModernHolidays() && day == 28) { 654 return YOM_YERUSHALAYIM; 655 } 656 break; 657 case SIVAN: 658 if (day == 5) { 659 return EREV_SHAVUOS; 660 } 661 if (day == 6 || (day == 7 && !inIsrael)) { 662 return SHAVUOS; 663 } 664 if ((day == 7 && inIsrael) || (day == 8 && !inIsrael)) { 665 return ISRU_CHAG; 666 } 667 break; 668 case TAMMUZ: 669 // push off the fast day if it falls on Shabbos 670 if ((day == 17 && dayOfWeek != Calendar.SATURDAY) 671 || (day == 18 && dayOfWeek == Calendar.SUNDAY)) { 672 return SEVENTEEN_OF_TAMMUZ; 673 } 674 break; 675 case AV: 676 // if Tisha B'av falls on Shabbos, push off until Sunday 677 if ((dayOfWeek == Calendar.SUNDAY && day == 10) 678 || (dayOfWeek != Calendar.SATURDAY && day == 9)) { 679 return TISHA_BEAV; 680 } 681 if (day == 15) { 682 return TU_BEAV; 683 } 684 break; 685 case ELUL: 686 if (day == 29) { 687 return EREV_ROSH_HASHANA; 688 } 689 break; 690 case TISHREI: 691 if (day == 1 || day == 2) { 692 return ROSH_HASHANA; 693 } 694 if ((day == 3 && dayOfWeek != Calendar.SATURDAY) || (day == 4 && dayOfWeek == Calendar.SUNDAY)) { 695 // push off Tzom Gedalia if it falls on Shabbos 696 return FAST_OF_GEDALYAH; 697 } 698 if (day == 9) { 699 return EREV_YOM_KIPPUR; 700 } 701 if (day == 10) { 702 return YOM_KIPPUR; 703 } 704 if (day == 14) { 705 return EREV_SUCCOS; 706 } 707 if (day == 15 || (day == 16 && !inIsrael)) { 708 return SUCCOS; 709 } 710 if (day >= 17 && day <= 20 || (day == 16 && inIsrael)) { 711 return CHOL_HAMOED_SUCCOS; 712 } 713 if (day == 21) { 714 return HOSHANA_RABBA; 715 } 716 if (day == 22) { 717 return SHEMINI_ATZERES; 718 } 719 if (day == 23 && !inIsrael) { 720 return SIMCHAS_TORAH; 721 } 722 if ((day == 23 && inIsrael) || (day == 24 && !inIsrael)) { 723 return ISRU_CHAG; 724 } 725 break; 726 case KISLEV: // no yomtov in CHESHVAN 727 // if (day == 24) { 728 // return EREV_CHANUKAH; 729 // } else 730 if (day >= 25) { 731 return CHANUKAH; 732 } 733 break; 734 case TEVES: 735 if (day == 1 || day == 2 736 || (day == 3 && isKislevShort())) { 737 return CHANUKAH; 738 } 739 if (day == 10) { 740 return TENTH_OF_TEVES; 741 } 742 break; 743 case SHEVAT: 744 if (day == 15) { 745 return TU_BESHVAT; 746 } 747 break; 748 case ADAR: 749 if (!isJewishLeapYear()) { 750 // if 13th Adar falls on Friday or Shabbos, push back to Thursday 751 if (((day == 11 || day == 12) && dayOfWeek == Calendar.THURSDAY) 752 || (day == 13 && !(dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY))) { 753 return FAST_OF_ESTHER; 754 } 755 if (day == 14) { 756 return PURIM; 757 } 758 if (day == 15) { 759 return SHUSHAN_PURIM; 760 } 761 } else { // else if a leap year 762 if (day == 14) { 763 return PURIM_KATAN; 764 } 765 if (day == 15) { 766 return SHUSHAN_PURIM_KATAN; 767 } 768 } 769 break; 770 case ADAR_II: 771 // if 13th Adar falls on Friday or Shabbos, push back to Thursday 772 if (((day == 11 || day == 12) && dayOfWeek == Calendar.THURSDAY) 773 || (day == 13 && !(dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY))) { 774 return FAST_OF_ESTHER; 775 } 776 if (day == 14) { 777 return PURIM; 778 } 779 if (day == 15) { 780 return SHUSHAN_PURIM; 781 } 782 break; 783 } 784 // if we get to this stage, then there are no holidays for the given date return -1 785 return -1; 786 } 787 788 /** 789 * Returns true if the current day is <em>Yom Tov</em>. The method returns true even for holidays such as {@link #CHANUKAH} 790 * and minor ones such as {@link #TU_BEAV} and {@link #PESACH_SHENI}. <em>Erev Yom Tov</em> (with the exception of 791 * {@link #HOSHANA_RABBA}, <em>erev</em> the second days of {@link #PESACH}) returns false, as do {@link #isTaanis() fast 792 * days} besides {@link #YOM_KIPPUR}. Use {@link #isAssurBemelacha()} to find the days that have a prohibition of work. 793 * 794 * @return true if the current day is a Yom Tov 795 * 796 * @see #getYomTovIndex() 797 * @see #isErevYomTov() 798 * @see #isErevYomTovSheni() 799 * @see #isTaanis() 800 * @see #isAssurBemelacha() 801 * @see #isCholHamoed() 802 */ 803 public boolean isYomTov() { 804 int holidayIndex = getYomTovIndex(); 805 if ((isErevYomTov() && (holidayIndex != HOSHANA_RABBA || (holidayIndex == CHOL_HAMOED_PESACH && getJewishDayOfMonth() != 20))) 806 || (isTaanis() && holidayIndex != YOM_KIPPUR) || holidayIndex == ISRU_CHAG) { 807 return false; 808 } 809 return getYomTovIndex() != -1; 810 } 811 812 /** 813 * Returns true if the <em>Yom Tov</em> day has a <em>melacha</em> (work) prohibition. This method will return false for a 814 * non-<em>Yom Tov</em> day, even if it is <em>Shabbos</em>. 815 * 816 * @return if the <em>Yom Tov</em> day has a <em>melacha</em> (work) prohibition. 817 */ 818 public boolean isYomTovAssurBemelacha() { 819 int holidayIndex = getYomTovIndex(); 820 return holidayIndex == PESACH || holidayIndex == SHAVUOS || holidayIndex == SUCCOS || holidayIndex == SHEMINI_ATZERES || 821 holidayIndex == SIMCHAS_TORAH || holidayIndex == ROSH_HASHANA || holidayIndex == YOM_KIPPUR; 822 } 823 824 /** 825 * Returns true if it is <em>Shabbos</em> or if it is a <em>Yom Tov</em> day that has a <em>melacha</em> (work) prohibition. 826 * 827 * @return if the day is a <em>Yom Tov</em> that is <em>assur bemlacha</em> or <em>Shabbos</em> 828 */ 829 public boolean isAssurBemelacha() { 830 return getDayOfWeek() == Calendar.SATURDAY || isYomTovAssurBemelacha(); 831 } 832 833 /** 834 * Returns true if the day has candle lighting. This will return true on <em>Erev Shabbos</em>, <em>Erev Yom Tov</em>, the 835 * first day of <em>Rosh Hashana</em> and the first days of <em>Yom Tov</em> out of Israel. It is identical 836 * to calling {@link #isTomorrowShabbosOrYomTov()}. 837 * 838 * @return if the day has candle lighting. 839 * 840 * @see #isTomorrowShabbosOrYomTov() 841 */ 842 public boolean hasCandleLighting() { 843 return isTomorrowShabbosOrYomTov(); 844 } 845 846 /** 847 * Returns true if tomorrow is <em>Shabbos</em> or <em>Yom Tov</em>. This will return true on <em>Erev Shabbos</em>, 848 * <em>Erev Yom Tov</em>, the first day of <em>Rosh Hashana</em> and <em>erev</em> the first days of <em>Yom Tov</em> 849 * out of Israel. It is identical to calling {@link #hasCandleLighting()}. 850 * 851 * @return will return if the next day is <em>Shabbos</em> or <em>Yom Tov</em>. 852 * 853 * @see #hasCandleLighting() 854 */ 855 public boolean isTomorrowShabbosOrYomTov() { 856 return getDayOfWeek() == Calendar.FRIDAY || isErevYomTov() || isErevYomTovSheni(); 857 } 858 859 /** 860 * Returns true if the day is the second day of <em>Yom Tov</em>. This impacts the second day of <em>Rosh Hashana</em> everywhere and 861 * the second days of Yom Tov in <em>chutz laaretz</em> (out of Israel). 862 * 863 * @return if the day is the second day of <em>Yom Tov</em>. 864 */ 865 public boolean isErevYomTovSheni() { 866 return (getJewishMonth() == TISHREI && (getJewishDayOfMonth() == 1)) 867 || (! getInIsrael() 868 && ((getJewishMonth() == NISSAN && (getJewishDayOfMonth() == 15 || getJewishDayOfMonth() == 21)) 869 || (getJewishMonth() == TISHREI && (getJewishDayOfMonth() == 15 || getJewishDayOfMonth() == 22)) 870 || (getJewishMonth() == SIVAN && getJewishDayOfMonth() == 6 ))); 871 } 872 873 /** 874 * Returns true if the current day is <em>Aseres Yemei Teshuva</em>. 875 * 876 * @return if the current day is <em>Aseres Yemei Teshuvah</em> 877 */ 878 public boolean isAseresYemeiTeshuva() { 879 return getJewishMonth() == TISHREI && getJewishDayOfMonth() <= 10; 880 } 881 882 /** 883 * Returns true if the current day is <em>Pesach</em> (either the <em>Yom Tov</em> of <em>Pesach</em> or<em>Chol Hamoed Pesach</em>). 884 * 885 * @return true if the current day is <em>Pesach</em> (either the <em>Yom Tov</em> of <em>Pesach</em> or<em>Chol Hamoed Pesach</em>). 886 * @see #isYomTov() 887 * @see #isCholHamoedPesach() 888 * @see #PESACH 889 * @see #CHOL_HAMOED_PESACH 890 */ 891 public boolean isPesach() { 892 int holidayIndex = getYomTovIndex(); 893 return holidayIndex == PESACH || holidayIndex == CHOL_HAMOED_PESACH; 894 } 895 896 /** 897 * Returns true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em>. 898 * 899 * @return true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> 900 * @see #isYomTov() 901 * @see #isPesach() 902 * @see #CHOL_HAMOED_PESACH 903 */ 904 public boolean isCholHamoedPesach() { 905 int holidayIndex = getYomTovIndex(); 906 return holidayIndex == CHOL_HAMOED_PESACH; 907 } 908 909 /** 910 * Returns true if the current day is <em>Shavuos</em>. 911 * 912 * @return true if the current day is <em>Shavuos</em>. 913 * @see #isYomTov() 914 * @see #SHAVUOS 915 */ 916 public boolean isShavuos() { 917 int holidayIndex = getYomTovIndex(); 918 return holidayIndex == SHAVUOS; 919 } 920 921 /** 922 * Returns true if the current day is <em>Rosh Hashana</em>. 923 * 924 * @return true if the current day is <em>Rosh Hashana</em>. 925 * @see #isYomTov() 926 * @see #ROSH_HASHANA 927 */ 928 public boolean isRoshHashana() { 929 int holidayIndex = getYomTovIndex(); 930 return holidayIndex == ROSH_HASHANA; 931 } 932 933 /** 934 * Returns true if the current day is <em>Yom Kippur</em>. 935 * 936 * @return true if the current day is <em>Yom Kippur</em>. 937 * @see #isYomTov() 938 * @see #YOM_KIPPUR 939 */ 940 public boolean isYomKippur() { 941 int holidayIndex = getYomTovIndex(); 942 return holidayIndex == YOM_KIPPUR; 943 } 944 945 /** 946 * Returns true if the current day is <em>Succos</em> (either the <em>Yom Tov</em> of <em>Succos</em> or<em>Chol Hamoed Succos</em>). 947 * It will return false for {@link #isShminiAtzeres() Shmini Atzeres} and {@link #isSimchasTorah() Simchas Torah}. 948 * 949 * @return true if the current day is <em>Succos</em> (either the <em>Yom Tov</em> of <em>Succos</em> or<em>Chol Hamoed Succos</em>. 950 * @see #isYomTov() 951 * @see #isCholHamoedSuccos() 952 * @see #isHoshanaRabba() 953 * @see #SUCCOS 954 * @see #CHOL_HAMOED_SUCCOS 955 * @see #HOSHANA_RABBA 956 */ 957 public boolean isSuccos() { 958 int holidayIndex = getYomTovIndex(); 959 return holidayIndex == SUCCOS || holidayIndex == CHOL_HAMOED_SUCCOS || holidayIndex == HOSHANA_RABBA; 960 } 961 962 /** 963 * Returns true if the current day is <em>Hoshana Rabba</em>. 964 * 965 * @return true true if the current day is <em>Hoshana Rabba</em>. 966 * @see #isYomTov() 967 * @see #HOSHANA_RABBA 968 */ 969 public boolean isHoshanaRabba() { 970 int holidayIndex = getYomTovIndex(); 971 return holidayIndex == HOSHANA_RABBA; 972 } 973 974 /** 975 * Returns true if the current day is <em>Shmini Atzeres</em>. 976 * 977 * @return true if the current day is <em>Shmini Atzeres</em>. 978 * @see #isYomTov() 979 * @see #SHEMINI_ATZERES 980 */ 981 public boolean isShminiAtzeres() { 982 int holidayIndex = getYomTovIndex(); 983 return holidayIndex == SHEMINI_ATZERES; 984 } 985 986 /** 987 * Returns true if the current day is <em>Simchas Torah</em>. This will always return false if {@link #getInIsrael() in Israel} 988 * 989 * @return true if the current day is <em>Shmini Atzeres</em>. 990 * @see #isYomTov() 991 * @see #SIMCHAS_TORAH 992 */ 993 public boolean isSimchasTorah() { 994 int holidayIndex = getYomTovIndex(); 995 //if in Israel, Holiday index of SIMCHAS_TORAH will not be returned by getYomTovIndex() 996 return holidayIndex == SIMCHAS_TORAH; 997 } 998 999 /** 1000 * Returns true if the current day is <em>Chol Hamoed</em> of <em>Succos</em>. 1001 * 1002 * @return true if the current day is <em>Chol Hamoed</em> of <em>Succos</em> 1003 * @see #isYomTov() 1004 * @see #CHOL_HAMOED_SUCCOS 1005 */ 1006 public boolean isCholHamoedSuccos() { 1007 int holidayIndex = getYomTovIndex(); 1008 return holidayIndex == CHOL_HAMOED_SUCCOS || holidayIndex == HOSHANA_RABBA; 1009 } 1010 1011 /** 1012 * Returns true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> or <em>Succos</em>. 1013 * 1014 * @return true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> or <em>Succos</em> 1015 * @see #isYomTov() 1016 * @see #CHOL_HAMOED_PESACH 1017 * @see #CHOL_HAMOED_SUCCOS 1018 */ 1019 public boolean isCholHamoed() { 1020 return isCholHamoedPesach() || isCholHamoedSuccos(); 1021 } 1022 1023 /** 1024 * Returns true if the current day is <em>Erev Yom Tov</em>. The method returns true for <em>Erev</em> - <em>Pesach</em> 1025 * (first and last days), <em>Shavuos</em>, <em>Rosh Hashana</em>, <em>Yom Kippur</em>, <em>Succos</em> and <em>Hoshana 1026 * Rabba</em>. 1027 * 1028 * @return true if the current day is <em>Erev</em> - <em>Pesach</em>, <em>Shavuos</em>, <em>Rosh Hashana</em>, <em>Yom 1029 * Kippur</em>, <em>Succos</em> and <em>Hoshana Rabba</em>. 1030 * @see #isYomTov() 1031 * @see #isErevYomTovSheni() 1032 */ 1033 public boolean isErevYomTov() { 1034 int holidayIndex = getYomTovIndex(); 1035 return holidayIndex == EREV_PESACH || holidayIndex == EREV_SHAVUOS || holidayIndex == EREV_ROSH_HASHANA 1036 || holidayIndex == EREV_YOM_KIPPUR || holidayIndex == EREV_SUCCOS || holidayIndex == HOSHANA_RABBA 1037 || (holidayIndex == CHOL_HAMOED_PESACH && getJewishDayOfMonth() == 20); 1038 } 1039 1040 /** 1041 * Returns true if the current day is <em>Erev Rosh Chodesh</em>. Returns false for <em>Erev Rosh Hashana</em>. 1042 * 1043 * @return true if the current day is <em>Erev Rosh Chodesh</em>. Returns false for <em>Erev Rosh Hashana</em>. 1044 * @see #isRoshChodesh() 1045 */ 1046 public boolean isErevRoshChodesh() { 1047 // Erev Rosh Hashana is not Erev Rosh Chodesh. 1048 return (getJewishDayOfMonth() == 29 && getJewishMonth() != ELUL); 1049 } 1050 1051 1052 /** 1053 * Returns true if the current day is <em>Yom Kippur Katan</em>. Returns false for <em>Erev Rosh Hashana</em>, 1054 * <em>Erev Rosh Chodesh Cheshvan</em>, <em>Teves</em> and <em>Iyyar</em>. If <em>Erev Rosh Chodesh</em> occurs 1055 * on a Friday or <em>Shabbos</em>, <em>Yom Kippur Katan</em> is moved back to Thursday. 1056 * 1057 * @return true if the current day is <em>Erev Rosh Chodesh</em>. Returns false for <em>Erev Rosh Hashana</em>. 1058 * @see #isRoshChodesh() 1059 */ 1060 public boolean isYomKippurKatan() { 1061 int dayOfWeek = getDayOfWeek(); 1062 int month = getJewishMonth(); 1063 int day = getJewishDayOfMonth(); 1064 if(month == JewishDate.ELUL || month == JewishDate.TISHREI || month == JewishDate.KISLEV || month == JewishDate.NISSAN) { 1065 return false; 1066 } 1067 1068 if(day == 29 && dayOfWeek != Calendar.FRIDAY && dayOfWeek != Calendar.SATURDAY) { 1069 return true; 1070 } 1071 1072 if((day == 27 || day == 28) && dayOfWeek == Calendar.THURSDAY ) { 1073 return true; 1074 } 1075 return false; 1076 } 1077 1078 /** 1079 * The Monday, Thursday and Monday after the first <em>Shabbos</em> after {@link #isRoshChodesh() <em>Rosh Chodesh</em>} 1080 * {@link JewishDate#CHESHVAN <em>Cheshvan</em>} and {@link JewishDate#IYAR <em>Iyar</em>} are <a href= 1081 * "https://outorah.org/p/41334/"> <em>BeHaB</em></a> days. If the last Monday of Iyar's BeHaB coincides with {@link 1082 * #PESACH_SHENI <em>Pesach Sheni</em>}, the method currently considers it both <em>Pesach Sheni</em> and <em>BeHaB</em>. 1083 * As seen in an Ohr Sameach article on the subject <a href="https://ohr.edu/this_week/insights_into_halacha/9340">The 1084 * unknown Days: BeHaB Vs. Pesach Sheini?</a> there are some customs that delay the day to various points in the future. 1085 * @return true if the day is <em>BeHaB</em>. 1086 */ 1087 public boolean isBeHaB() { 1088 int dayOfWeek = getDayOfWeek(); 1089 int month = getJewishMonth(); 1090 int day = getJewishDayOfMonth(); 1091 1092 if (month == JewishDate.CHESHVAN || month == JewishDate.IYAR) { 1093 if((dayOfWeek == Calendar.MONDAY && day > 4 && day < 18) 1094 || (dayOfWeek == Calendar.THURSDAY && day > 7 && day < 14)) { 1095 return true; 1096 } 1097 } 1098 return false; 1099 } 1100 1101 /** 1102 * Return true if the day is a Taanis (fast day). Return true for <em>17 of Tammuz</em>, <em>Tisha B'Av</em>, 1103 * <em>Yom Kippur</em>, <em>Fast of Gedalyah</em>, <em>10 of Teves</em> and the <em>Fast of Esther</em>. 1104 * 1105 * @return true if today is a fast day 1106 */ 1107 public boolean isTaanis() { 1108 int holidayIndex = getYomTovIndex(); 1109 return holidayIndex == SEVENTEEN_OF_TAMMUZ || holidayIndex == TISHA_BEAV || holidayIndex == YOM_KIPPUR 1110 || holidayIndex == FAST_OF_GEDALYAH || holidayIndex == TENTH_OF_TEVES || holidayIndex == FAST_OF_ESTHER; 1111 } 1112 1113 /** 1114 * Return true if the day is <em>Taanis Bechoros</em> (on <em>Erev Pesach</em>). It will return true for the 14th 1115 * of <em>Nissan</em> if it is not on <em>Shabbos</em>, or if the 12th of <em>Nissan</em> occurs on a Thursday. 1116 * 1117 * @return true if today is <em>Taanis Bechoros</em>. 1118 */ 1119 public boolean isTaanisBechoros() { 1120 final int day = getJewishDayOfMonth(); 1121 final int dayOfWeek = getDayOfWeek(); 1122 // on 14 Nissan unless that is Shabbos where the fast is moved back to Thursday 1123 return getJewishMonth() == NISSAN && ((day == 14 && dayOfWeek != Calendar.SATURDAY) || 1124 (day == 12 && dayOfWeek == Calendar.THURSDAY )); 1125 } 1126 1127 /** 1128 * Returns the day of <em>Chanukah</em> or -1 if it is not <em>Chanukah</em>. 1129 * 1130 * @return the day of <em>Chanukah</em> or -1 if it is not <em>Chanukah</em>. 1131 * @see #isChanukah() 1132 */ 1133 public int getDayOfChanukah() { 1134 final int day = getJewishDayOfMonth(); 1135 if (isChanukah()) { 1136 if (getJewishMonth() == KISLEV) { 1137 return day - 24; 1138 } else { // teves 1139 return isKislevShort() ? day + 5 : day + 6; 1140 } 1141 } else { 1142 return -1; 1143 } 1144 } 1145 1146 /** 1147 * Returns true if the current day is one of the 8 days of <em>Chanukah</em>. 1148 * 1149 * @return if the current day is one of the 8 days of <em>Chanukah</em>. 1150 * 1151 * @see #getDayOfChanukah() 1152 */ 1153 public boolean isChanukah() { 1154 return getYomTovIndex() == CHANUKAH; 1155 } 1156 1157 /** 1158 * Returns if the day is Purim (<a href="https://en.wikipedia.org/wiki/Purim#Shushan_Purim">Shushan Purim</a> 1159 * in a mukaf choma and regular Purim in a non-mukaf choma). 1160 * @return if the day is Purim (Shushan Purim in a mukaf choma and regular Purin in a non-mukaf choma) 1161 * 1162 * @see #getIsMukafChoma() 1163 * @see #setIsMukafChoma(boolean) 1164 */ 1165 public boolean isPurim() { 1166 if(isMukafChoma) { 1167 return getYomTovIndex() == SHUSHAN_PURIM; 1168 } else { 1169 return getYomTovIndex() == PURIM; 1170 } 1171 } 1172 1173 /** 1174 * Returns if the day is Rosh Chodesh. Rosh Hashana will return false 1175 * 1176 * @return true if it is Rosh Chodesh. Rosh Hashana will return false 1177 */ 1178 public boolean isRoshChodesh() { 1179 // Rosh Hashana is not rosh chodesh. Elul never has 30 days 1180 return (getJewishDayOfMonth() == 1 && getJewishMonth() != TISHREI) || getJewishDayOfMonth() == 30; 1181 } 1182 1183 /** 1184 * Returns if the day is <em>Shabbos</em> and Sunday is <em>Rosh Chodesh</em>. 1185 * 1186 * @return true if it is <em>Shabbos</em> and Sunday is <em>Rosh Chodesh</em>. 1187 * @todo There is more to tweak in this method (it does not cover all cases and opinions), and it may be removed. 1188 */ 1189 public boolean isMacharChodesh() { 1190 return (getDayOfWeek() == Calendar.SATURDAY && (getJewishDayOfMonth() == 30 || getJewishDayOfMonth() == 29)); 1191 } 1192 1193 /** 1194 * Returns if the day is <em>Shabbos Mevorchim</em>. 1195 * 1196 * @return true if it is <em>Shabbos Mevorchim</em>. 1197 */ 1198 public boolean isShabbosMevorchim() { 1199 return (getDayOfWeek() == Calendar.SATURDAY && getJewishDayOfMonth() >= 23 && getJewishDayOfMonth() <= 29 && getJewishMonth() != ELUL); 1200 } 1201 1202 /** 1203 * Returns the int value of the <em>Omer</em> day or -1 if the day is not in the <em>Omer</em>. 1204 * 1205 * @return The <em>Omer</em> count as an int or -1 if it is not a day of the <em>Omer</em>. 1206 */ 1207 public int getDayOfOmer() { 1208 int omer = -1; // not a day of the Omer 1209 int month = getJewishMonth(); 1210 int day = getJewishDayOfMonth(); 1211 1212 // if Nissan and second day of Pesach and on 1213 if (month == NISSAN && day >= 16) { 1214 omer = day - 15; 1215 // if Iyar 1216 } else if (month == IYAR) { 1217 omer = day + 15; 1218 // if Sivan and before Shavuos 1219 } else if (month == SIVAN && day < 6) { 1220 omer = day + 44; 1221 } 1222 return omer; 1223 } 1224 1225 /** 1226 * Returns if the day is Tisha Be'Av (the 9th of Av). 1227 * @return if the day is Tisha Be'Av (the 9th of Av). 1228 */ 1229 public boolean isTishaBav() { 1230 int holidayIndex = getYomTovIndex(); 1231 return holidayIndex == TISHA_BEAV; 1232 } 1233 1234 /** 1235 * Returns the <em>molad</em> in Standard Time in Yerushalayim as a Date. The traditional calculation uses local time. 1236 * This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the local time (of <em>Har Habayis</em> 1237 * with a longitude of 35.2354° is 5.2354° away from the %15 timezone longitude) to get to standard time. This 1238 * method intentionally uses standard time and not daylight savings time. Java will implicitly format the time to the 1239 * default (or set) Timezone. 1240 * 1241 * @return the Date representing the moment of the <em>molad</em> in Yerushalayim standard time (GMT + 2) 1242 */ 1243 public Date getMoladAsDate() { 1244 JewishDate molad = getMolad(); 1245 String locationName = "Jerusalem, Israel"; 1246 1247 double latitude = 31.778; // Har Habayis latitude 1248 double longitude = 35.2354; // Har Habayis longitude 1249 1250 // The raw molad Date (point in time) must be generated using standard time. Using "Asia/Jerusalem" timezone will result in the time 1251 // being incorrectly off by an hour in the summer due to DST. Proper adjustment for the actual time in DST will be done by the date 1252 // formatter class used to display the Date. 1253 TimeZone yerushalayimStandardTZ = TimeZone.getTimeZone("GMT+2"); 1254 GeoLocation geo = new GeoLocation(locationName, latitude, longitude, yerushalayimStandardTZ); 1255 Calendar cal = Calendar.getInstance(geo.getTimeZone()); 1256 cal.clear(); 1257 double moladSeconds = molad.getMoladChalakim() * 10 / (double) 3; 1258 cal.set(molad.getGregorianYear(), molad.getGregorianMonth(), molad.getGregorianDayOfMonth(), 1259 molad.getMoladHours(), molad.getMoladMinutes(), (int) moladSeconds); 1260 cal.set(Calendar.MILLISECOND, (int) (1000 * (moladSeconds - (int) moladSeconds))); 1261 // subtract local time difference of 20.94 minutes (20 minutes and 56.496 seconds) to get to Standard time 1262 cal.add(Calendar.MILLISECOND, -1 * (int) geo.getLocalMeanTimeOffset()); 1263 return cal.getTime(); 1264 } 1265 1266 /** 1267 * Returns the earliest time of <em>Kiddush Levana</em> calculated as 3 days after the molad. This method returns the time 1268 * even if it is during the day when <em>Kiddush Levana</em> can't be said. Callers of this method should consider 1269 * displaying the next <em>tzais</em> if the <em>zman</em> is between <em>alos</em> and <em>tzais</em>. 1270 * 1271 * @return the Date representing the moment 3 days after the molad. 1272 * 1273 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana3Days() 1274 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana3Days(Date, Date) 1275 */ 1276 public Date getTchilasZmanKidushLevana3Days() { 1277 Date molad = getMoladAsDate(); 1278 Calendar cal = Calendar.getInstance(); 1279 cal.setTime(molad); 1280 cal.add(Calendar.HOUR, 72); // 3 days after the molad 1281 return cal.getTime(); 1282 } 1283 1284 /** 1285 * Returns the earliest time of <em>Kiddush Levana</em> calculated as 7 days after the <em>molad</em> as mentioned 1286 * by the <a href="http://en.wikipedia.org/wiki/Yosef_Karo">Mechaber</a>. See the <a 1287 * href="http://en.wikipedia.org/wiki/Yoel_Sirkis">Bach's</a> opinion on this time. This method returns the time 1288 * even if it is during the day when <em>Kiddush Levana</em> can't be said. Callers of this method should consider 1289 * displaying the next <em>tzais</em> if the <em>zman</em> is between <em>alos</em> and <em>tzais</em>. 1290 * 1291 * @return the Date representing the moment 7 days after the molad. 1292 * 1293 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana7Days() 1294 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana7Days(Date, Date) 1295 */ 1296 public Date getTchilasZmanKidushLevana7Days() { 1297 Date molad = getMoladAsDate(); 1298 Calendar cal = Calendar.getInstance(); 1299 cal.setTime(molad); 1300 cal.add(Calendar.HOUR, 168); // 7 days after the molad 1301 return cal.getTime(); 1302 } 1303 1304 /** 1305 * Returns the latest time of Kiddush Levana according to the <a 1306 * href="http://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin">Maharil's</a> opinion that it is calculated as 1307 * halfway between <em>molad</em> and <em>molad</em>. This adds half the 29 days, 12 hours and 793 <em>chalakim</em> 1308 * time between <em>molad</em> and <em>molad</em> (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's 1309 * <em>molad</em>. This method returns the time even if it is during the day when <em>Kiddush Levana</em> can't be 1310 * recited. Callers of this method should consider displaying <em>alos</em> before this time if the <em>zman</em> is 1311 * between <em>alos</em> and <em>tzais</em>. 1312 * 1313 * @return the Date representing the moment halfway between <em>molad</em> and <em>molad</em>. 1314 * 1315 * @see #getSofZmanKidushLevana15Days() 1316 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevanaBetweenMoldos() 1317 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevanaBetweenMoldos(Date, Date) 1318 */ 1319 public Date getSofZmanKidushLevanaBetweenMoldos() { 1320 Date molad = getMoladAsDate(); 1321 Calendar cal = Calendar.getInstance(); 1322 cal.setTime(molad); 1323 // add half the time between molad and molad (half of 29 days, 12 hours and 793 chalakim (44 minutes, 3.3 1324 // seconds), or 14 days, 18 hours, 22 minutes and 666 milliseconds). Add it as hours, not days, to avoid 1325 // DST/ST crossover issues. 1326 cal.add(Calendar.HOUR, (24 * 14) + 18); 1327 cal.add(Calendar.MINUTE, 22); 1328 cal.add(Calendar.SECOND, 1); 1329 cal.add(Calendar.MILLISECOND, 666); 1330 return cal.getTime(); 1331 } 1332 1333 /** 1334 * Returns the latest time of <em>Kiddush Levana</em> calculated as 15 days after the <em>molad.</em> This is the 1335 * opinion brought down in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that 1336 * the <a href="http://en.wikipedia.org/wiki/Moses_Isserles">Rema</a> who brings down the the <a 1337 * href="http://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin">Maharil's</a> opinion of calculating it as 1338 * {@link #getSofZmanKidushLevanaBetweenMoldos() half way between <em>molad</em> and <em>molad</em>} is of the 1339 * opinion of the Mechaber as well. Also see the Aruch Hashulchan. For additional details on the subject, See Rabbi 1340 * Dovid Heber's very detailed writeup in Siman Daled (chapter 4) of <a 1341 * href="http://www.worldcat.org/oclc/461326125">Shaarei Zmanim</a>. This method returns the time even if it is during 1342 * the day when <em>Kiddush Levana</em> can't be said. Callers of this method should consider displaying <em>alos</em> 1343 * before this time if the <em>zman</em> is between <em>alos</em> and <em>tzais</em>. 1344 * 1345 * @return the Date representing the moment 15 days after the <em>molad</em>. 1346 * @see #getSofZmanKidushLevanaBetweenMoldos() 1347 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevana15Days() 1348 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevana15Days(Date, Date) 1349 */ 1350 public Date getSofZmanKidushLevana15Days() { 1351 Date molad = getMoladAsDate(); 1352 Calendar cal = Calendar.getInstance(); 1353 cal.setTime(molad); 1354 cal.add(Calendar.HOUR, 24 * 15); //15 days after the molad. Add it as hours, not days, to avoid DST/ST crossover issues. 1355 return cal.getTime(); 1356 } 1357 1358 /** 1359 * Returns the <em>Daf Yomi (Bavli)</em> for the date that the calendar is set to. See the 1360 * {@link HebrewDateFormatter#formatDafYomiBavli(Daf)} for the ability to format the <em>daf</em> in 1361 * Hebrew or transliterated <em>masechta</em> names. 1362 * 1363 * @return the daf as a {@link Daf} 1364 */ 1365 public Daf getDafYomiBavli() { 1366 return YomiCalculator.getDafYomiBavli(this); 1367 } 1368 /** 1369 * Returns the <em>Daf Yomi (Yerushalmi)</em> for the date that the calendar is set to. See the 1370 * {@link HebrewDateFormatter#formatDafYomiYerushalmi(Daf)} for the ability to format the <em>daf</em> 1371 * in Hebrew or transliterated <em>masechta</em> names. 1372 * 1373 * @return the daf as a {@link Daf} 1374 */ 1375 public Daf getDafYomiYerushalmi() { 1376 return YerushalmiYomiCalculator.getDafYomiYerushalmi(this); 1377 } 1378 1379 /** 1380 * Returns the elapsed days since <em>Tekufas Tishrei</em>. This uses <em>Tekufas Shmuel</em> (identical to the <a href= 1381 * "https://en.wikipedia.org/wiki/Julian_year_(astronomy)">Julian Year</a> with a solar year length of 365.25 days). 1382 * The notation used below is D = days, H = hours and C = chalakim. <em><a href="https://en.wikipedia.org/wiki/Molad" 1383 * >Molad</a> BaHaRad</em> was 2D,5H,204C or 5H,204C from the start of <em>Rosh Hashana</em> year 1. For <em>molad 1384 * Nissan</em> add 177D, 4H and 438C (6 * 29D, 12H and 793C), or 177D,9H,642C after <em>Rosh Hashana</em> year 1. 1385 * <em>Tekufas Nissan</em> was 7D, 9H and 642C before <em>molad Nissan</em> according to the Rambam, or 170D, 0H and 1386 * 0C after <em>Rosh Hashana</em> year 1. <em>Tekufas Tishrei</em> was 182D and 3H (365.25 / 2) before <em>tekufas 1387 * Nissan</em>, or 12D and 15H before <em>Rosh Hashana</em> of year 1. Outside of Israel we start reciting <em>Tal 1388 * Umatar</em> in <em>Birkas Hashanim</em> from 60 days after <em>tekufas Tishrei</em>. The 60 days include the day of 1389 * the <em>tekufah</em> and the day we start reciting <em>Tal Umatar</em>. 60 days from the tekufah == 47D and 9H 1390 * from <em>Rosh Hashana</em> year 1. 1391 * 1392 * @return the number of elapsed days since <em>tekufas Tishrei</em>. 1393 * 1394 * @see #isVeseinTalUmatarStartDate() 1395 * @see #isVeseinTalUmatarStartingTonight() 1396 * @see #isVeseinTalUmatarRecited() 1397 */ 1398 public int getTekufasTishreiElapsedDays() { 1399 // Days since Rosh Hashana year 1. Add 1/2 day as the first tekufas tishrei was 9 hours into the day. This allows all 1400 // 4 years of the secular leap year cycle to share 47 days. Truncate 47D and 9H to 47D for simplicity. 1401 double days = getJewishCalendarElapsedDays(getJewishYear()) + (getDaysSinceStartOfJewishYear()-1) + 0.5; 1402 // days of completed solar years 1403 double solar = (getJewishYear() - 1) * 365.25; 1404 return (int) Math.floor(days - solar); 1405 } 1406 1407 /** 1408 * Returns if it is the Jewish day (starting the evening before) to start reciting <em>Vesein Tal Umatar 1409 * Livracha</em> (<em>Sheailas Geshamim</em>). In Israel this is the 7th day of <em>Marcheshvan</em>. Outside 1410 * Israel recitation starts on the evening of December 4th (or 5th if it is the year before a civil leap year) 1411 * in the 21st century and shifts a day forward every century not evenly divisible by 400. This method will 1412 * return true if <em>vesein tal umatar</em> on the current Jewish date that starts on the previous night, so 1413 * Dec 5/6 will be returned by this method in the 21st century. <em>vesein tal umatar</em> is not recited on 1414 * <em>Shabbos</em> and the start date will be delayed a day when the start day is on a <em>Shabbos</em> (this 1415 * can only occur out of Israel). 1416 * 1417 * @deprecated Use {@link TefilaRules#isVeseinTalUmatarStartDate(JewishCalendar)} instead. This method will be 1418 * removed in the v3.0 release. 1419 * 1420 * @return true if it is the first Jewish day (starting the prior evening of reciting <em>Vesein Tal Umatar 1421 * Livracha</em> (<em>Sheailas Geshamim</em>)). 1422 * 1423 * @see #isVeseinTalUmatarStartingTonight() 1424 * @see #isVeseinTalUmatarRecited() 1425 */ 1426 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1427 public boolean isVeseinTalUmatarStartDate() { 1428 if (inIsrael) { 1429 // The 7th Cheshvan can't occur on Shabbos, so always return true for 7 Cheshvan 1430 if (getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 7) { 1431 return true; 1432 } 1433 } else { 1434 if (getDayOfWeek() == Calendar.SATURDAY) { //Not recited on Friday night 1435 return false; 1436 } 1437 if (getDayOfWeek() == Calendar.SUNDAY) { // When starting on Sunday, it can be the start date or delayed from Shabbos 1438 return getTekufasTishreiElapsedDays() == 48 || getTekufasTishreiElapsedDays() == 47; 1439 } else { 1440 return getTekufasTishreiElapsedDays() == 47; 1441 } 1442 } 1443 return false; // keep the compiler happy 1444 } 1445 1446 /** 1447 * Returns true if tonight is the first night to start reciting <em>Vesein Tal Umatar Livracha</em> ( 1448 * <em>Sheailas Geshamim</em>). In Israel this is the 7th day of <em>Marcheshvan</em> (so the 6th will return 1449 * true). Outside Israel recitation starts on the evening of December 4th (or 5th if it is the year before a 1450 * civil leap year) in the 21st century and shifts a day forward every century not evenly divisible by 400. 1451 * <em>Vesein tal umatar</em> is not recited on <em>Shabbos</em> and the start date will be delayed a day when 1452 * the start day is on a <em>Shabbos</em> (this can only occur out of Israel). 1453 * 1454 * @deprecated Use {@link TefilaRules#isVeseinTalUmatarStartingTonight(JewishCalendar)} instead. This method 1455 * will be removed in the v3.0 release. 1456 * 1457 * @return true if it is the first Jewish day (starting the prior evening of reciting <em>Vesein Tal Umatar 1458 * Livracha</em> (<em>Sheailas Geshamim</em>)). 1459 * 1460 * @see #isVeseinTalUmatarStartDate() 1461 * @see #isVeseinTalUmatarRecited() 1462 */ 1463 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1464 public boolean isVeseinTalUmatarStartingTonight() { 1465 if (inIsrael) { 1466 // The 7th Cheshvan can't occur on Shabbos, so always return true for 6 Cheshvan 1467 if (getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 6) { 1468 return true; 1469 } 1470 } else { 1471 if (getDayOfWeek() == Calendar.FRIDAY) { //Not recited on Friday night 1472 return false; 1473 } 1474 if (getDayOfWeek() == Calendar.SATURDAY) { // When starting on motzai Shabbos, it can be the start date or delayed from Friday night 1475 return getTekufasTishreiElapsedDays() == 47 || getTekufasTishreiElapsedDays() == 46; 1476 } else { 1477 return getTekufasTishreiElapsedDays() == 46; 1478 } 1479 } 1480 return false; 1481 } 1482 1483 /** 1484 * Returns if <em>Vesein Tal Umatar Livracha</em> (<em>Sheailas Geshamim</em>) is recited. This will return 1485 * true for the entire season, even on <em>Shabbos</em> when it is not recited. 1486 * 1487 * @deprecated Use {@link TefilaRules#isVeseinTalUmatarRecited(JewishCalendar)} instead. This method will 1488 * be removed in the v3.0 release. 1489 * 1490 * @return true if <em>Vesein Tal Umatar Livracha</em> (<em>Sheailas Geshamim</em>) is recited. 1491 * 1492 * @see #isVeseinTalUmatarStartDate() 1493 * @see #isVeseinTalUmatarStartingTonight() 1494 */ 1495 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1496 public boolean isVeseinTalUmatarRecited() { 1497 if (getJewishMonth() == NISSAN && getJewishDayOfMonth() < 15) { 1498 return true; 1499 } 1500 if (getJewishMonth() < CHESHVAN) { 1501 return false; 1502 } 1503 if (inIsrael) { 1504 return getJewishMonth() != CHESHVAN || getJewishDayOfMonth() >= 7; 1505 } else { 1506 return getTekufasTishreiElapsedDays() >= 47; 1507 } 1508 } 1509 1510 /** 1511 * Returns if <em>Vesein Beracha</em> is recited. It is recited from 15 <em>Nissan</em> to the point that {@link 1512 * #isVeseinTalUmatarRecited() <em>vesein tal umatar</em> is recited}. 1513 * 1514 * @deprecated Use {@link TefilaRules#isVeseinBerachaRecited(JewishCalendar)} instead. This method will be 1515 * removed in the v3.0 release. 1516 * 1517 * @return true if <em>Vesein Beracha</em> is recited. 1518 * 1519 * @see #isVeseinTalUmatarRecited() 1520 */ 1521 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1522 public boolean isVeseinBerachaRecited() { 1523 return !isVeseinTalUmatarRecited(); 1524 } 1525 1526 /** 1527 * Returns if the date is the start date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. The date is 22 <em>Tishrei</em>. 1528 * 1529 * @deprecated Use {@link TefilaRules#isMashivHaruachStartDate(JewishCalendar)} instead. This method will be 1530 * removed in the v3.0 release. 1531 * 1532 * @return true if the date is the start date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. 1533 * 1534 * @see #isMashivHaruachEndDate() 1535 * @see #isMashivHaruachRecited() 1536 */ 1537 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1538 public boolean isMashivHaruachStartDate() { 1539 return getJewishMonth() == TISHREI && getJewishDayOfMonth() == 22; 1540 } 1541 1542 /** 1543 * Returns if the date is the end date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. The date is 15 <em>Nissan</em>. 1544 * 1545 * @deprecated Use {@link TefilaRules#isMashivHaruachEndDate(JewishCalendar)} instead. This method will be 1546 * removed in the v3.0 release. 1547 * 1548 * @return true if the date is the end date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. 1549 * 1550 * @see #isMashivHaruachStartDate() 1551 * @see #isMashivHaruachRecited() 1552 */ 1553 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1554 public boolean isMashivHaruachEndDate() { 1555 return getJewishMonth() == NISSAN && getJewishDayOfMonth() == 15; 1556 } 1557 1558 /** 1559 * Returns if <em>Mashiv Haruach Umorid Hageshem</em> is recited. This period starts on 22 <em>Tishrei</em> and ends 1560 * on the 15th day of <em>Nissan</em>. 1561 * 1562 * @deprecated Use {@link TefilaRules#isMashivHaruachRecited(JewishCalendar)} instead. This method will be 1563 * removed in the v3.0 release. 1564 * 1565 * @return true if <em>Mashiv Haruach Umorid Hageshem</em> is recited. 1566 * 1567 * @see #isMashivHaruachStartDate() 1568 * @see #isMashivHaruachEndDate() 1569 */ 1570 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1571 public boolean isMashivHaruachRecited() { 1572 JewishDate startDate = new JewishDate(getJewishYear(), TISHREI, 22); 1573 JewishDate endDate = new JewishDate(getJewishYear(), NISSAN, 15); 1574 return compareTo(startDate) > 0 && compareTo(endDate) < 0; 1575 } 1576 1577 /** 1578 * Returns if <em>Morid Hatal</em> (or the lack of reciting <em>Mashiv Haruach</em> following <em>nussach Ashkenaz</em>) is recited. 1579 * This period starts on 22 <em>Tishrei</em> and ends on the 15th day of 1580 * <em>Nissan</em>. 1581 * 1582 * @deprecated Use {@link TefilaRules#isMoridHatalRecited(JewishCalendar)} instead. This method will be 1583 * removed in the v3.0 release. 1584 * 1585 * @return true if <em>Morid Hatal</em> (or the lack of reciting <em>Mashiv Haruach</em> following <em>nussach Ashkenaz</em>) is recited. 1586 */ 1587 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1588 public boolean isMoridHatalRecited() { 1589 return !isMashivHaruachRecited() || isMashivHaruachStartDate() || isMashivHaruachEndDate(); 1590 } 1591 1592 /** 1593 * Returns true if the current day is <em>Isru Chag</em>. The method returns true for the day following <em>Pesach</em> 1594 * <em>Shavuos</em> and <em>Succos</em>. It utilizes {@see #getInIsrael()} to return the proper date. 1595 * 1596 * @return true if the current day is <em>Isru Chag</em>. The method returns true for the day following <em>Pesach</em> 1597 * <em>Shavuos</em> and <em>Succos</em>. It utilizes {@see #getInIsrael()} to return the proper date. 1598 */ 1599 public boolean isIsruChag() { 1600 int holidayIndex = getYomTovIndex(); 1601 return holidayIndex == ISRU_CHAG; 1602 } 1603 1604 /** 1605 * Indicates whether some other object is "equal to" this one. 1606 * @see Object#equals(Object) 1607 */ 1608 public boolean equals(Object object) { 1609 if (this == object) { 1610 return true; 1611 } 1612 if (!(object instanceof JewishCalendar)) { 1613 return false; 1614 } 1615 JewishCalendar jewishCalendar = (JewishCalendar) object; 1616 return getAbsDate() == jewishCalendar.getAbsDate() && getInIsrael() == jewishCalendar.getInIsrael(); 1617 } 1618 1619 /** 1620 * Overrides {@link Object#hashCode()}. 1621 * @see Object#hashCode() 1622 */ 1623 public int hashCode() { 1624 int result = 17; 1625 result = 37 * result + getClass().hashCode(); // needed or this and subclasses will return identical hash 1626 result += 37 * result + getAbsDate() + (getInIsrael() ? 1 : 3); 1627 return result; 1628 } 1629}