001/* 002 * Zmanim Java API 003 * Copyright (C) 2011 - 2024 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 - 2024 046 */ 047public class JewishCalendar extends JewishDate { 048 /** The 14th day of Nissan, the day before 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 Tammuz*/ 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 and second days 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 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 morning resulting in the 172 used in the calculation. 389 */ 390 return elapsedDays % (28 * 365.25) == 172; // 28 years of 365.25 days + the offset from molad tohu mentioned above 391 } 392 393 /** 394 * Return the type of year for <em>parsha</em> calculations. The algorithm follows the 395 * <a href="http://hebrewbooks.org/pdfpager.aspx?req=14268&st=&pgnum=222">Luach Arba'ah Shearim</a> in the Tur Ohr Hachaim. 396 * @return the type of year for <em>parsha</em> calculations. 397 */ 398 private int getParshaYearType() { 399 int roshHashanaDayOfWeek = (getJewishCalendarElapsedDays(getJewishYear()) + 1) % 7; // plus one to the original Rosh Hashana of year 1 to get a week starting on Sunday 400 if (roshHashanaDayOfWeek == 0) { 401 roshHashanaDayOfWeek = 7; // convert 0 to 7 for Shabbos for readability 402 } 403 if (isJewishLeapYear()) { 404 switch (roshHashanaDayOfWeek) { 405 case Calendar.MONDAY: 406 if (isKislevShort()) { //BaCh 407 if (getInIsrael()) { 408 return 14; 409 } 410 return 6; 411 } 412 if (isCheshvanLong()) { //BaSh 413 if (getInIsrael()) { 414 return 15; 415 } 416 return 7; 417 } 418 break; 419 case Calendar.TUESDAY: //Gak 420 if (getInIsrael()) { 421 return 15; 422 } 423 return 7; 424 case Calendar.THURSDAY: 425 if (isKislevShort()) { //HaCh 426 return 8; 427 } 428 if (isCheshvanLong()) { //HaSh 429 return 9; 430 } 431 break; 432 case Calendar.SATURDAY: 433 if (isKislevShort()) { //ZaCh 434 return 10; 435 } 436 if (isCheshvanLong()) { //ZaSh 437 if (getInIsrael()) { 438 return 16; 439 } 440 return 11; 441 } 442 break; 443 } 444 } else { //not a leap year 445 switch (roshHashanaDayOfWeek) { 446 case Calendar.MONDAY: 447 if (isKislevShort()) { //BaCh 448 return 0; 449 } 450 if (isCheshvanLong()) { //BaSh 451 if (getInIsrael()) { 452 return 12; 453 } 454 return 1; 455 } 456 break; 457 case Calendar.TUESDAY: //GaK 458 if (getInIsrael()) { 459 return 12; 460 } 461 return 1; 462 case Calendar.THURSDAY: 463 if (isCheshvanLong()) { //HaSh 464 return 3; 465 } 466 if (!isKislevShort()) { //Hak 467 if (getInIsrael()) { 468 return 13; 469 } 470 return 2; 471 } 472 break; 473 case Calendar.SATURDAY: 474 if (isKislevShort()) { //ZaCh 475 return 4; 476 } 477 if (isCheshvanLong()) { //ZaSh 478 return 5; 479 } 480 break; 481 } 482 } 483 return -1; //keep the compiler happy 484 } 485 486 /** 487 * Returns this week's {@link Parsha <em>Parsha</em>} if it is <em>Shabbos</em>. It returns {@link Parsha#NONE} if the date 488 * 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>). 489 * 490 * @return the current <em>parsha</em>. 491 */ 492 public Parsha getParshah() { 493 if (getDayOfWeek() != Calendar.SATURDAY) { 494 return Parsha.NONE; 495 } 496 497 int yearType = getParshaYearType(); 498 int roshHashanaDayOfWeek = getJewishCalendarElapsedDays(getJewishYear()) % 7; 499 int day = roshHashanaDayOfWeek + getDaysSinceStartOfJewishYear(); 500 501 if (yearType >= 0) { // negative year should be impossible, but let's cover all bases 502 return parshalist[yearType][day/7]; 503 } 504 return Parsha.NONE; //keep the compiler happy 505 } 506 507 /** 508 * Returns the upcoming {@link Parsha <em>Parsha</em>} regardless of if it is the weekday or <em>Shabbos</em> (where next 509 * Shabbos's <em>Parsha</em> will be returned. This is unlike {@link #getParshah()} that returns {@link Parsha#NONE} if 510 * 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 511 * following week's <em>Parsha</em> will be returned. 512 * 513 * @return the upcoming <em>parsha</em>. 514 */ 515 public Parsha getUpcomingParshah() { 516 JewishCalendar clone = (JewishCalendar) clone(); 517 int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7; 518 if (getDayOfWeek() != Calendar.SATURDAY) { 519 clone.forward(Calendar.DATE, daysToShabbos); 520 } else { 521 clone.forward(Calendar.DATE, 7); 522 } 523 while(clone.getParshah() == Parsha.NONE) { //Yom Kippur / Sukkos or Pesach with 2 potential non-parsha Shabbosim in a row 524 clone.forward(Calendar.DATE, 7); 525 } 526 return clone.getParshah(); 527 } 528 529 /** 530 * Returns a {@link Parsha <em>Parsha</em>} enum if the <em>Shabbos</em> is one of the four <em>parshiyos</em> of {@link 531 * Parsha#SHKALIM <em>Shkalim</em>}, {@link Parsha#ZACHOR <em>Zachor</em>}, {@link Parsha#PARA <em>Para</em>}, {@link 532 * Parsha#HACHODESH <em>Hachdesh</em>}, or five other special <em>Shabbasos</em> of {@link Parsha#HAGADOL <em>Hagadol</em>}, 533 * {@link Parsha#CHAZON <em>Chazon</em>}, {@link Parsha#NACHAMU <em>Nachamu</em>}, {@link Parsha#SHUVA <em>Shuva</em>}, 534 * {@link Parsha#SHIRA <em>Shira</em>}, or {@link Parsha#NONE Parsha.NONE} for a regular <em>Shabbos</em> (or any weekday). 535 * 536 * @return one of the four <em>parshiyos</em> of {@link Parsha#SHKALIM <em>Shkalim</em>}, {@link Parsha#ZACHOR <em>Zachor</em>}, 537 * {@link Parsha#PARA <em>Para</em>}, {@link Parsha#HACHODESH <em>Hachodesh</em>}, or five other special <em>Shabbasos</em> 538 * of {@link Parsha#HAGADOL <em>Hagadol</em>}, {@link Parsha#CHAZON <em>Chazon</em>}, {@link Parsha#NACHAMU <em>Nachamu</em>}, 539 * {@link Parsha#SHUVA <em>Shuva</em>}, {@link Parsha#SHIRA <em>Shira</em>}, or {@link Parsha#NONE Parsha.NONE} for a regular 540 * <em>Shabbos</em> (or any weekday). 541 */ 542 public Parsha getSpecialShabbos() { 543 if (getDayOfWeek() == Calendar.SATURDAY) { 544 if ((getJewishMonth() == SHEVAT && !isJewishLeapYear()) || (getJewishMonth() == ADAR && isJewishLeapYear())) { 545 if (getJewishDayOfMonth() == 25 || getJewishDayOfMonth() == 27 || getJewishDayOfMonth() == 29) { 546 return Parsha.SHKALIM; 547 } 548 } 549 if ((getJewishMonth() == ADAR && !isJewishLeapYear()) || getJewishMonth() == ADAR_II) { 550 if (getJewishDayOfMonth() == 1) { 551 return Parsha.SHKALIM; 552 } 553 if (getJewishDayOfMonth() == 8 || getJewishDayOfMonth() == 9 || getJewishDayOfMonth() == 11 || getJewishDayOfMonth() == 13) { 554 return Parsha.ZACHOR; 555 } 556 if (getJewishDayOfMonth() == 18 || getJewishDayOfMonth() == 20 || getJewishDayOfMonth() == 22 || getJewishDayOfMonth() == 23) { 557 return Parsha.PARA; 558 } 559 if (getJewishDayOfMonth() == 25 || getJewishDayOfMonth() == 27 || getJewishDayOfMonth() == 29) { 560 return Parsha.HACHODESH; 561 } 562 } 563 if (getJewishMonth() == NISSAN) { 564 if (getJewishDayOfMonth() == 1) { 565 return Parsha.HACHODESH; 566 } 567 if (getJewishDayOfMonth() >= 8 && getJewishDayOfMonth() <= 14) { 568 return Parsha.HAGADOL; 569 } 570 } 571 if (getJewishMonth() == AV) { 572 if (getJewishDayOfMonth() >= 4 && getJewishDayOfMonth() <= 9) { 573 return Parsha.CHAZON; 574 } 575 if (getJewishDayOfMonth() >= 10 && getJewishDayOfMonth() <= 16) { 576 return Parsha.NACHAMU; 577 } 578 } 579 if (getJewishMonth() == TISHREI) { 580 if (getJewishDayOfMonth() >= 3 && getJewishDayOfMonth() <= 8) { 581 return Parsha.SHUVA; 582 } 583 584 } 585 if (getParshah() == Parsha.BESHALACH) { 586 return Parsha.SHIRA; 587 } 588 } 589 return Parsha.NONE; 590 } 591 592 /** 593 * 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. 594 * There are constants in this class representing each <em>Yom Tov</em>. Formatting of the <em>Yomim tovim</em> is done 595 * in the {@link HebrewDateFormatter#formatYomTov(JewishCalendar)}. 596 * 597 * @todo Consider using enums instead of the constant ints. 598 * 599 * @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. 600 * 601 * @see HebrewDateFormatter#formatYomTov(JewishCalendar) 602 */ 603 public int getYomTovIndex() { 604 final int day = getJewishDayOfMonth(); 605 final int dayOfWeek = getDayOfWeek(); 606 607 // check by month (starting from Nissan) 608 switch (getJewishMonth()) { 609 case NISSAN: 610 if (day == 14) { 611 return EREV_PESACH; 612 } 613 if (day == 15 || day == 21 614 || (!inIsrael && (day == 16 || day == 22))) { 615 return PESACH; 616 } 617 if (day >= 17 && day <= 20 || day == 16) { 618 return CHOL_HAMOED_PESACH; 619 } 620 if (day == 22 || day == 23 && !inIsrael) { 621 return ISRU_CHAG; 622 } 623 if (isUseModernHolidays() 624 && ((day == 26 && dayOfWeek == Calendar.THURSDAY) 625 || (day == 28 && dayOfWeek == Calendar.MONDAY) 626 || (day == 27 && dayOfWeek != Calendar.SUNDAY && dayOfWeek != Calendar.FRIDAY))) { 627 return YOM_HASHOAH; 628 } 629 break; 630 case IYAR: 631 if (isUseModernHolidays() 632 && ((day == 4 && dayOfWeek == Calendar.TUESDAY) 633 || ((day == 3 || day == 2) && dayOfWeek == Calendar.WEDNESDAY) || (day == 5 && dayOfWeek == Calendar.MONDAY))) { 634 return YOM_HAZIKARON; 635 } 636 // if 5 Iyar falls on Wed, Yom Haatzmaut is that day. If it falls on Friday or Shabbos, it is moved back to 637 // Thursday. If it falls on Monday it is moved to Tuesday 638 if (isUseModernHolidays() 639 && ((day == 5 && dayOfWeek == Calendar.WEDNESDAY) 640 || ((day == 4 || day == 3) && dayOfWeek == Calendar.THURSDAY) || (day == 6 && dayOfWeek == Calendar.TUESDAY))) { 641 return YOM_HAATZMAUT; 642 } 643 if (day == 14) { 644 return PESACH_SHENI; 645 } 646 if (day == 18) { 647 return LAG_BAOMER; 648 } 649 if (isUseModernHolidays() && day == 28) { 650 return YOM_YERUSHALAYIM; 651 } 652 break; 653 case SIVAN: 654 if (day == 5) { 655 return EREV_SHAVUOS; 656 } 657 if (day == 6 || (day == 7 && !inIsrael)) { 658 return SHAVUOS; 659 } 660 if (day == 7 || day == 8 && !inIsrael) { 661 return ISRU_CHAG; 662 } 663 break; 664 case TAMMUZ: 665 // push off the fast day if it falls on Shabbos 666 if ((day == 17 && dayOfWeek != Calendar.SATURDAY) 667 || (day == 18 && dayOfWeek == Calendar.SUNDAY)) { 668 return SEVENTEEN_OF_TAMMUZ; 669 } 670 break; 671 case AV: 672 // if Tisha B'av falls on Shabbos, push off until Sunday 673 if ((dayOfWeek == Calendar.SUNDAY && day == 10) 674 || (dayOfWeek != Calendar.SATURDAY && day == 9)) { 675 return TISHA_BEAV; 676 } 677 if (day == 15) { 678 return TU_BEAV; 679 } 680 break; 681 case ELUL: 682 if (day == 29) { 683 return EREV_ROSH_HASHANA; 684 } 685 break; 686 case TISHREI: 687 if (day == 1 || day == 2) { 688 return ROSH_HASHANA; 689 } 690 if ((day == 3 && dayOfWeek != Calendar.SATURDAY) || (day == 4 && dayOfWeek == Calendar.SUNDAY)) { 691 // push off Tzom Gedalia if it falls on Shabbos 692 return FAST_OF_GEDALYAH; 693 } 694 if (day == 9) { 695 return EREV_YOM_KIPPUR; 696 } 697 if (day == 10) { 698 return YOM_KIPPUR; 699 } 700 if (day == 14) { 701 return EREV_SUCCOS; 702 } 703 if (day == 15 || (day == 16 && !inIsrael)) { 704 return SUCCOS; 705 } 706 if (day >= 16 && day <= 20) { 707 return CHOL_HAMOED_SUCCOS; 708 } 709 if (day == 21) { 710 return HOSHANA_RABBA; 711 } 712 if (day == 22) { 713 return SHEMINI_ATZERES; 714 } 715 if (day == 23 && !inIsrael) { 716 return SIMCHAS_TORAH; 717 } 718 if (day == 23 || day == 24 && !inIsrael) { 719 return ISRU_CHAG; 720 } 721 break; 722 case KISLEV: // no yomtov in CHESHVAN 723 // if (day == 24) { 724 // return EREV_CHANUKAH; 725 // } else 726 if (day >= 25) { 727 return CHANUKAH; 728 } 729 break; 730 case TEVES: 731 if (day == 1 || day == 2 732 || (day == 3 && isKislevShort())) { 733 return CHANUKAH; 734 } 735 if (day == 10) { 736 return TENTH_OF_TEVES; 737 } 738 break; 739 case SHEVAT: 740 if (day == 15) { 741 return TU_BESHVAT; 742 } 743 break; 744 case ADAR: 745 if (!isJewishLeapYear()) { 746 // if 13th Adar falls on Friday or Shabbos, push back to Thursday 747 if (((day == 11 || day == 12) && dayOfWeek == Calendar.THURSDAY) 748 || (day == 13 && !(dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY))) { 749 return FAST_OF_ESTHER; 750 } 751 if (day == 14) { 752 return PURIM; 753 } 754 if (day == 15) { 755 return SHUSHAN_PURIM; 756 } 757 } else { // else if a leap year 758 if (day == 14) { 759 return PURIM_KATAN; 760 } 761 if (day == 15) { 762 return SHUSHAN_PURIM_KATAN; 763 } 764 } 765 break; 766 case ADAR_II: 767 // if 13th Adar falls on Friday or Shabbos, push back to Thursday 768 if (((day == 11 || day == 12) && dayOfWeek == Calendar.THURSDAY) 769 || (day == 13 && !(dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY))) { 770 return FAST_OF_ESTHER; 771 } 772 if (day == 14) { 773 return PURIM; 774 } 775 if (day == 15) { 776 return SHUSHAN_PURIM; 777 } 778 break; 779 } 780 // if we get to this stage, then there are no holidays for the given date return -1 781 return -1; 782 } 783 784 /** 785 * Returns true if the current day is <em>Yom Tov</em>. The method returns true even for holidays such as {@link #CHANUKAH} 786 * and minor ones such as {@link #TU_BEAV} and {@link #PESACH_SHENI}. <em>Erev Yom Tov</em> (with the exception of 787 * {@link #HOSHANA_RABBA} and <em>erev</em> the second days of {@link #PESACH}) returns false, as do {@link #isTaanis() fast 788 * days} besides {@link #YOM_KIPPUR}. Use {@link #isAssurBemelacha()} to find the days that have a prohibition of work. 789 * 790 * @return true if the current day is a Yom Tov 791 * 792 * @see #getYomTovIndex() 793 * @see #isErevYomTov() 794 * @see #isErevYomTovSheni() 795 * @see #isTaanis() 796 * @see #isAssurBemelacha() 797 * @see #isCholHamoed() 798 */ 799 public boolean isYomTov() { 800 int holidayIndex = getYomTovIndex(); 801 if ((isErevYomTov() && ! ( holidayIndex == HOSHANA_RABBA || holidayIndex == CHOL_HAMOED_PESACH)) 802 || (isTaanis() && holidayIndex != YOM_KIPPUR) || holidayIndex == ISRU_CHAG) { 803 return false; 804 } 805 return getYomTovIndex() != -1; 806 } 807 808 /** 809 * Returns true if the <em>Yom Tov</em> day has a <em>melacha</em> (work) prohibition. This method will return false for a 810 * non-<em>Yom Tov</em> day, even if it is <em>Shabbos</em>. 811 * 812 * @return if the <em>Yom Tov</em> day has a <em>melacha</em> (work) prohibition. 813 */ 814 public boolean isYomTovAssurBemelacha() { 815 int holidayIndex = getYomTovIndex(); 816 return holidayIndex == PESACH || holidayIndex == SHAVUOS || holidayIndex == SUCCOS || holidayIndex == SHEMINI_ATZERES || 817 holidayIndex == SIMCHAS_TORAH || holidayIndex == ROSH_HASHANA || holidayIndex == YOM_KIPPUR; 818 } 819 820 /** 821 * 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. 822 * 823 * @return if the day is a <em>Yom Tov</em> that is <em>assur bemlacha</em> or <em>Shabbos</em> 824 */ 825 public boolean isAssurBemelacha() { 826 return getDayOfWeek() == Calendar.SATURDAY || isYomTovAssurBemelacha(); 827 } 828 829 /** 830 * Returns true if the day has candle lighting. This will return true on <em>Erev Shabbos</em>, <em>Erev Yom Tov</em>, the 831 * first day of <em>Rosh Hashana</em> and the first days of <em>Yom Tov</em> out of Israel. It is identical 832 * to calling {@link #isTomorrowShabbosOrYomTov()}. 833 * 834 * @return if the day has candle lighting. 835 * 836 * @see #isTomorrowShabbosOrYomTov() 837 */ 838 public boolean hasCandleLighting() { 839 return isTomorrowShabbosOrYomTov(); 840 } 841 842 /** 843 * Returns true if tomorrow is <em>Shabbos</em> or <em>Yom Tov</em>. This will return true on <em>Erev Shabbos</em>, 844 * <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> 845 * out of Israel. It is identical to calling {@link #hasCandleLighting()}. 846 * 847 * @return will return if the next day is <em>Shabbos</em> or <em>Yom Tov</em>. 848 * 849 * @see #hasCandleLighting() 850 */ 851 public boolean isTomorrowShabbosOrYomTov() { 852 return getDayOfWeek() == Calendar.FRIDAY || isErevYomTov() || isErevYomTovSheni(); 853 } 854 855 /** 856 * 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 857 * the second days of Yom Tov in <em>chutz laaretz</em> (out of Israel). 858 * 859 * @return if the day is the second day of <em>Yom Tov</em>. 860 */ 861 public boolean isErevYomTovSheni() { 862 return (getJewishMonth() == TISHREI && (getJewishDayOfMonth() == 1)) 863 || (! getInIsrael() 864 && ((getJewishMonth() == NISSAN && (getJewishDayOfMonth() == 15 || getJewishDayOfMonth() == 21)) 865 || (getJewishMonth() == TISHREI && (getJewishDayOfMonth() == 15 || getJewishDayOfMonth() == 22)) 866 || (getJewishMonth() == SIVAN && getJewishDayOfMonth() == 6 ))); 867 } 868 869 /** 870 * Returns true if the current day is <em>Aseres Yemei Teshuva</em>. 871 * 872 * @return if the current day is <em>Aseres Yemei Teshuva</em> 873 */ 874 public boolean isAseresYemeiTeshuva() { 875 return getJewishMonth() == TISHREI && getJewishDayOfMonth() <= 10; 876 } 877 878 /** 879 * 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>). 880 * 881 * @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>). 882 * @see #isYomTov() 883 * @see #isCholHamoedPesach() 884 * @see #PESACH 885 * @see #CHOL_HAMOED_PESACH 886 */ 887 public boolean isPesach() { 888 int holidayIndex = getYomTovIndex(); 889 return holidayIndex == PESACH || holidayIndex == CHOL_HAMOED_PESACH; 890 } 891 892 /** 893 * Returns true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em>. 894 * 895 * @return true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> 896 * @see #isYomTov() 897 * @see #isPesach() 898 * @see #CHOL_HAMOED_PESACH 899 */ 900 public boolean isCholHamoedPesach() { 901 int holidayIndex = getYomTovIndex(); 902 return holidayIndex == CHOL_HAMOED_PESACH; 903 } 904 905 /** 906 * Returns true if the current day is <em>Shavuos</em>. 907 * 908 * @return true if the current day is <em>Shavuos</em>. 909 * @see #isYomTov() 910 * @see #SHAVUOS 911 */ 912 public boolean isShavuos() { 913 int holidayIndex = getYomTovIndex(); 914 return holidayIndex == SHAVUOS; 915 } 916 917 /** 918 * Returns true if the current day is <em>Rosh Hashana</em>. 919 * 920 * @return true if the current day is <em>Rosh Hashana</em>. 921 * @see #isYomTov() 922 * @see #ROSH_HASHANA 923 */ 924 public boolean isRoshHashana() { 925 int holidayIndex = getYomTovIndex(); 926 return holidayIndex == ROSH_HASHANA; 927 } 928 929 /** 930 * Returns true if the current day is <em>Yom Kippur</em>. 931 * 932 * @return true if the current day is <em>Yom Kippur</em>. 933 * @see #isYomTov() 934 * @see #YOM_KIPPUR 935 */ 936 public boolean isYomKippur() { 937 int holidayIndex = getYomTovIndex(); 938 return holidayIndex == YOM_KIPPUR; 939 } 940 941 /** 942 * 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>). 943 * It will return false for {@link #isShminiAtzeres() Shmini Atzeres} and {@link #isSimchasTorah() Simchas Torah}. 944 * 945 * @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>. 946 * @see #isYomTov() 947 * @see #isCholHamoedSuccos() 948 * @see #isHoshanaRabba() 949 * @see #SUCCOS 950 * @see #CHOL_HAMOED_SUCCOS 951 * @see #HOSHANA_RABBA 952 */ 953 public boolean isSuccos() { 954 int holidayIndex = getYomTovIndex(); 955 return holidayIndex == SUCCOS || holidayIndex == CHOL_HAMOED_SUCCOS || holidayIndex == HOSHANA_RABBA; 956 } 957 958 /** 959 * Returns true if the current day is <em>Hoshana Rabba</em>. 960 * 961 * @return true if the current day is <em>Hoshana Rabba</em>. 962 * @see #isYomTov() 963 * @see #HOSHANA_RABBA 964 */ 965 public boolean isHoshanaRabba() { 966 int holidayIndex = getYomTovIndex(); 967 return holidayIndex == HOSHANA_RABBA; 968 } 969 970 /** 971 * Returns true if the current day is <em>Shmini Atzeres</em>. 972 * 973 * @return true if the current day is <em>Shmini Atzeres</em>. 974 * @see #isYomTov() 975 * @see #SHEMINI_ATZERES 976 */ 977 public boolean isShminiAtzeres() { 978 int holidayIndex = getYomTovIndex(); 979 return holidayIndex == SHEMINI_ATZERES; 980 } 981 982 /** 983 * Returns true if the current day is <em>Simchas Torah</em>. This will always return false if {@link #getInIsrael() in Israel} 984 * 985 * @return true if the current day is <em>Shmini Atzeres</em>. 986 * @see #isYomTov() 987 * @see #SIMCHAS_TORAH 988 */ 989 public boolean isSimchasTorah() { 990 int holidayIndex = getYomTovIndex(); 991 //if in Israel, Holiday index of SIMCHAS_TORAH will not be returned by getYomTovIndex() 992 return holidayIndex == SIMCHAS_TORAH; 993 } 994 995 /** 996 * Returns true if the current day is <em>Chol Hamoed</em> of <em>Succos</em>. 997 * 998 * @return true if the current day is <em>Chol Hamoed</em> of <em>Succos</em> 999 * @see #isYomTov() 1000 * @see #CHOL_HAMOED_SUCCOS 1001 */ 1002 public boolean isCholHamoedSuccos() { 1003 int holidayIndex = getYomTovIndex(); 1004 return holidayIndex == CHOL_HAMOED_SUCCOS || holidayIndex == HOSHANA_RABBA; 1005 } 1006 1007 /** 1008 * Returns true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> or <em>Succos</em>. 1009 * 1010 * @return true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> or <em>Succos</em> 1011 * @see #isYomTov() 1012 * @see #CHOL_HAMOED_PESACH 1013 * @see #CHOL_HAMOED_SUCCOS 1014 */ 1015 public boolean isCholHamoed() { 1016 return isCholHamoedPesach() || isCholHamoedSuccos(); 1017 } 1018 1019 /** 1020 * Returns true if the current day is <em>Erev Yom Tov</em>. The method returns true for <em>Erev</em> - <em>Pesach</em> 1021 * (first and last days), <em>Shavuos</em>, <em>Rosh Hashana</em>, <em>Yom Kippur</em>, <em>Succos</em> and <em>Hoshana 1022 * Rabba</em>. 1023 * 1024 * @return true if the current day is <em>Erev</em> - <em>Pesach</em>, <em>Shavuos</em>, <em>Rosh Hashana</em>, <em>Yom 1025 * Kippur</em>, <em>Succos</em> and <em>Hoshana Rabba</em>. 1026 * @see #isYomTov() 1027 * @see #isErevYomTovSheni() 1028 */ 1029 public boolean isErevYomTov() { 1030 int holidayIndex = getYomTovIndex(); 1031 return holidayIndex == EREV_PESACH || holidayIndex == EREV_SHAVUOS || holidayIndex == EREV_ROSH_HASHANA 1032 || holidayIndex == EREV_YOM_KIPPUR || holidayIndex == EREV_SUCCOS || holidayIndex == HOSHANA_RABBA 1033 || (holidayIndex == CHOL_HAMOED_PESACH && getJewishDayOfMonth() == 20); 1034 } 1035 1036 /** 1037 * Returns true if the current day is <em>Erev Rosh Chodesh</em>. Returns false for <em>Erev Rosh Hashana</em>. 1038 * 1039 * @return true if the current day is <em>Erev Rosh Chodesh</em>. Returns false for <em>Erev Rosh Hashana</em>. 1040 * @see #isRoshChodesh() 1041 */ 1042 public boolean isErevRoshChodesh() { 1043 // Erev Rosh Hashana is not Erev Rosh Chodesh. 1044 return (getJewishDayOfMonth() == 29 && getJewishMonth() != ELUL); 1045 } 1046 1047 1048 /** 1049 * Returns true if the current day is <em>Yom Kippur Katan</em>. Returns false for <em>Erev Rosh Hashana</em>, 1050 * <em>Erev Rosh Chodesh Cheshvan</em>, <em>Teves</em> and <em>Iyyar</em>. If <em>Erev Rosh Chodesh</em> occurs 1051 * on a Friday or <em>Shabbos</em>, <em>Yom Kippur Katan</em> is moved back to Thursday. 1052 * 1053 * @return true if the current day is <em>Erev Rosh Chodesh</em>. Returns false for <em>Erev Rosh Hashana</em>. 1054 * @see #isRoshChodesh() 1055 */ 1056 public boolean isYomKippurKatan() { 1057 int dayOfWeek = getDayOfWeek(); 1058 int month = getJewishMonth(); 1059 int day = getJewishDayOfMonth(); 1060 if (month == JewishDate.ELUL || month == JewishDate.TISHREI || month == JewishDate.KISLEV || month == JewishDate.NISSAN) { 1061 return false; 1062 } 1063 1064 if (day == 29 && dayOfWeek != Calendar.FRIDAY && dayOfWeek != Calendar.SATURDAY) { 1065 return true; 1066 } 1067 return (day == 27 || day == 28) && dayOfWeek == Calendar.THURSDAY; 1068 } 1069 1070 /** 1071 * The Monday, Thursday and Monday after the first <em>Shabbos</em> after {@link #isRoshChodesh() <em>Rosh Chodesh</em>} 1072 * {@link JewishDate#CHESHVAN <em>Cheshvan</em>} and {@link JewishDate#IYAR <em>Iyar</em>} are <a href= 1073 * "https://outorah.org/p/41334/"> <em>BeHaB</em></a> days. If the last Monday of Iyar's BeHaB coincides with {@link 1074 * #PESACH_SHENI <em>Pesach Sheni</em>}, the method currently considers it both <em>Pesach Sheni</em> and <em>BeHaB</em>. 1075 * As seen in an Ohr Sameach article on the subject <a href="https://ohr.edu/this_week/insights_into_halacha/9340">The 1076 * unknown Days: BeHaB Vs. Pesach Sheini?</a> there are some customs that delay the day to various points in the future. 1077 * @return true if the day is <em>BeHaB</em>. 1078 */ 1079 public boolean isBeHaB() { 1080 int dayOfWeek = getDayOfWeek(); 1081 int month = getJewishMonth(); 1082 int day = getJewishDayOfMonth(); 1083 1084 if (month == JewishDate.CHESHVAN || month == JewishDate.IYAR) { 1085 return (dayOfWeek == Calendar.MONDAY && day > 4 && day < 18) 1086 || (dayOfWeek == Calendar.THURSDAY && day > 7 && day < 14); 1087 } 1088 return false; 1089 } 1090 1091 /** 1092 * Return true if the day is a Taanis (fast day). Return true for <em>17 of Tammuz</em>, <em>Tisha B'Av</em>, 1093 * <em>Yom Kippur</em>, <em>Fast of Gedalyah</em>, <em>10 of Teves</em> and the <em>Fast of Esther</em>. 1094 * 1095 * @return true if today is a fast day 1096 */ 1097 public boolean isTaanis() { 1098 int holidayIndex = getYomTovIndex(); 1099 return holidayIndex == SEVENTEEN_OF_TAMMUZ || holidayIndex == TISHA_BEAV || holidayIndex == YOM_KIPPUR 1100 || holidayIndex == FAST_OF_GEDALYAH || holidayIndex == TENTH_OF_TEVES || holidayIndex == FAST_OF_ESTHER; 1101 } 1102 1103 /** 1104 * Return true if the day is <em>Taanis Bechoros</em> (on <em>Erev Pesach</em>). It will return true for the 14th 1105 * of <em>Nissan</em> if it is not on <em>Shabbos</em>, or if the 12th of <em>Nissan</em> occurs on a Thursday. 1106 * 1107 * @return true if today is <em>Taanis Bechoros</em>. 1108 */ 1109 public boolean isTaanisBechoros() { 1110 final int day = getJewishDayOfMonth(); 1111 final int dayOfWeek = getDayOfWeek(); 1112 // on 14 Nissan unless that is Shabbos where the fast is moved back to Thursday 1113 return getJewishMonth() == NISSAN && ((day == 14 && dayOfWeek != Calendar.SATURDAY) || 1114 (day == 12 && dayOfWeek == Calendar.THURSDAY )); 1115 } 1116 1117 /** 1118 * Returns the day of <em>Chanukah</em> or -1 if it is not <em>Chanukah</em>. 1119 * 1120 * @return the day of <em>Chanukah</em> or -1 if it is not <em>Chanukah</em>. 1121 * @see #isChanukah() 1122 */ 1123 public int getDayOfChanukah() { 1124 final int day = getJewishDayOfMonth(); 1125 if (isChanukah()) { 1126 if (getJewishMonth() == KISLEV) { 1127 return day - 24; 1128 } else { // teves 1129 return isKislevShort() ? day + 5 : day + 6; 1130 } 1131 } else { 1132 return -1; 1133 } 1134 } 1135 1136 /** 1137 * Returns true if the current day is one of the 8 days of <em>Chanukah</em>. 1138 * 1139 * @return if the current day is one of the 8 days of <em>Chanukah</em>. 1140 * 1141 * @see #getDayOfChanukah() 1142 */ 1143 public boolean isChanukah() { 1144 return getYomTovIndex() == CHANUKAH; 1145 } 1146 1147 /** 1148 * Returns if the day is Purim (<a href="https://en.wikipedia.org/wiki/Purim#Shushan_Purim">Shushan Purim</a> 1149 * in a mukaf choma and regular Purim in a non-mukaf choma). 1150 * @return if the day is Purim (Shushan Purim in a mukaf choma and regular Purim in a non-mukaf choma) 1151 * 1152 * @see #getIsMukafChoma() 1153 * @see #setIsMukafChoma(boolean) 1154 */ 1155 public boolean isPurim() { 1156 if (isMukafChoma) { 1157 return getYomTovIndex() == SHUSHAN_PURIM; 1158 } else { 1159 return getYomTovIndex() == PURIM; 1160 } 1161 } 1162 1163 /** 1164 * Returns if the day is Rosh Chodesh. Rosh Hashana will return false 1165 * 1166 * @return true if it is Rosh Chodesh. Rosh Hashana will return false 1167 */ 1168 public boolean isRoshChodesh() { 1169 // Rosh Hashana is not rosh chodesh. Elul never has 30 days 1170 return (getJewishDayOfMonth() == 1 && getJewishMonth() != TISHREI) || getJewishDayOfMonth() == 30; 1171 } 1172 1173 /** 1174 * Returns if the day is <em>Shabbos</em> and Sunday is <em>Rosh Chodesh</em>. 1175 * 1176 * @return true if it is <em>Shabbos</em> and Sunday is <em>Rosh Chodesh</em>. 1177 * @todo There is more to tweak in this method (it does not cover all cases and opinions), and it may be removed. 1178 */ 1179 public boolean isMacharChodesh() { 1180 return (getDayOfWeek() == Calendar.SATURDAY && (getJewishDayOfMonth() == 30 || getJewishDayOfMonth() == 29)); 1181 } 1182 1183 /** 1184 * Returns if the day is <em>Shabbos Mevorchim</em>. 1185 * 1186 * @return true if it is <em>Shabbos Mevorchim</em>. 1187 */ 1188 public boolean isShabbosMevorchim() { 1189 return (getDayOfWeek() == Calendar.SATURDAY && getJewishDayOfMonth() >= 23 && getJewishDayOfMonth() <= 29 && getJewishMonth() != ELUL); 1190 } 1191 1192 /** 1193 * Returns the int value of the <em>Omer</em> day or -1 if the day is not in the <em>Omer</em>. 1194 * 1195 * @return The <em>Omer</em> count as an int or -1 if it is not a day of the <em>Omer</em>. 1196 */ 1197 public int getDayOfOmer() { 1198 int omer = -1; // not a day of the Omer 1199 int month = getJewishMonth(); 1200 int day = getJewishDayOfMonth(); 1201 1202 // if Nissan and second day of Pesach and on 1203 if (month == NISSAN && day >= 16) { 1204 omer = day - 15; 1205 // if Iyar 1206 } else if (month == IYAR) { 1207 omer = day + 15; 1208 // if Sivan and before Shavuos 1209 } else if (month == SIVAN && day < 6) { 1210 omer = day + 44; 1211 } 1212 return omer; 1213 } 1214 1215 /** 1216 * Returns if the day is Tisha Be'Av (the 9th of Av). 1217 * @return if the day is Tisha Be'Av (the 9th of Av). 1218 */ 1219 public boolean isTishaBav() { 1220 int holidayIndex = getYomTovIndex(); 1221 return holidayIndex == TISHA_BEAV; 1222 } 1223 1224 /** 1225 * Returns the <em>molad</em> in Standard Time in Yerushalayim as a Date. The traditional calculation uses local time. 1226 * This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the local time (of <em>Har Habayis</em> 1227 * with a longitude of 35.2354° is 5.2354° away from the %15 timezone longitude) to get to standard time. This 1228 * method intentionally uses standard time and not daylight savings time. Java will implicitly format the time to the 1229 * default (or set) Timezone. 1230 * 1231 * @return the Date representing the moment of the <em>molad</em> in Yerushalayim standard time (GMT + 2) 1232 */ 1233 public Date getMoladAsDate() { 1234 JewishDate molad = getMolad(); 1235 String locationName = "Jerusalem, Israel"; 1236 1237 double latitude = 31.778; // Har Habayis latitude 1238 double longitude = 35.2354; // Har Habayis longitude 1239 1240 // The raw molad Date (point in time) must be generated using standard time. Using "Asia/Jerusalem" timezone will result in the time 1241 // 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 1242 // formatter class used to display the Date. 1243 TimeZone yerushalayimStandardTZ = TimeZone.getTimeZone("GMT+2"); 1244 GeoLocation geo = new GeoLocation(locationName, latitude, longitude, yerushalayimStandardTZ); 1245 Calendar cal = Calendar.getInstance(geo.getTimeZone()); 1246 cal.clear(); 1247 double moladSeconds = molad.getMoladChalakim() * 10 / (double) 3; 1248 cal.set(molad.getGregorianYear(), molad.getGregorianMonth(), molad.getGregorianDayOfMonth(), 1249 molad.getMoladHours(), molad.getMoladMinutes(), (int) moladSeconds); 1250 cal.set(Calendar.MILLISECOND, (int) (1000 * (moladSeconds - (int) moladSeconds))); 1251 // subtract local time difference of 20.94 minutes (20 minutes and 56.496 seconds) to get to Standard time 1252 cal.add(Calendar.MILLISECOND, -1 * (int) geo.getLocalMeanTimeOffset()); 1253 return cal.getTime(); 1254 } 1255 1256 /** 1257 * Returns the earliest time of <em>Kiddush Levana</em> calculated as 3 days after the molad. This method returns the time 1258 * even if it is during the day when <em>Kiddush Levana</em> can't be said. Callers of this method should consider 1259 * displaying the next <em>tzais</em> if the <em>zman</em> is between <em>alos</em> and <em>tzais</em>. 1260 * 1261 * @return the Date representing the moment 3 days after the molad. 1262 * 1263 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana3Days() 1264 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana3Days(Date, Date) 1265 */ 1266 public Date getTchilasZmanKidushLevana3Days() { 1267 Date molad = getMoladAsDate(); 1268 Calendar cal = Calendar.getInstance(); 1269 cal.setTime(molad); 1270 cal.add(Calendar.HOUR, 72); // 3 days after the molad 1271 return cal.getTime(); 1272 } 1273 1274 /** 1275 * Returns the earliest time of <em>Kiddush Levana</em> calculated as 7 days after the <em>molad</em> as mentioned 1276 * by the <a href="http://en.wikipedia.org/wiki/Yosef_Karo">Mechaber</a>. See the <a 1277 * href="http://en.wikipedia.org/wiki/Yoel_Sirkis">Bach's</a> opinion on this time. This method returns the time 1278 * even if it is during the day when <em>Kiddush Levana</em> can't be said. Callers of this method should consider 1279 * displaying the next <em>tzais</em> if the <em>zman</em> is between <em>alos</em> and <em>tzais</em>. 1280 * 1281 * @return the Date representing the moment 7 days after the molad. 1282 * 1283 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana7Days() 1284 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana7Days(Date, Date) 1285 */ 1286 public Date getTchilasZmanKidushLevana7Days() { 1287 Date molad = getMoladAsDate(); 1288 Calendar cal = Calendar.getInstance(); 1289 cal.setTime(molad); 1290 cal.add(Calendar.HOUR, 168); // 7 days after the molad 1291 return cal.getTime(); 1292 } 1293 1294 /** 1295 * Returns the latest time of Kiddush Levana according to the <a 1296 * href="http://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin">Maharil's</a> opinion that it is calculated as 1297 * halfway between <em>molad</em> and <em>molad</em>. This adds half the 29 days, 12 hours and 793 <em>chalakim</em> 1298 * time between <em>molad</em> and <em>molad</em> (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's 1299 * <em>molad</em>. This method returns the time even if it is during the day when <em>Kiddush Levana</em> can't be 1300 * recited. Callers of this method should consider displaying <em>alos</em> before this time if the <em>zman</em> is 1301 * between <em>alos</em> and <em>tzais</em>. 1302 * 1303 * @return the Date representing the moment halfway between <em>molad</em> and <em>molad</em>. 1304 * 1305 * @see #getSofZmanKidushLevana15Days() 1306 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevanaBetweenMoldos() 1307 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevanaBetweenMoldos(Date, Date) 1308 */ 1309 public Date getSofZmanKidushLevanaBetweenMoldos() { 1310 Date molad = getMoladAsDate(); 1311 Calendar cal = Calendar.getInstance(); 1312 cal.setTime(molad); 1313 // add half the time between molad and molad (half of 29 days, 12 hours and 793 chalakim (44 minutes, 3.3 1314 // seconds), or 14 days, 18 hours, 22 minutes and 666 milliseconds). Add it as hours, not days, to avoid 1315 // DST/ST crossover issues. 1316 cal.add(Calendar.HOUR, (24 * 14) + 18); 1317 cal.add(Calendar.MINUTE, 22); 1318 cal.add(Calendar.SECOND, 1); 1319 cal.add(Calendar.MILLISECOND, 666); 1320 return cal.getTime(); 1321 } 1322 1323 /** 1324 * Returns the latest time of <em>Kiddush Levana</em> calculated as 15 days after the <em>molad.</em> This is the 1325 * opinion brought down in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that 1326 * the <a href="http://en.wikipedia.org/wiki/Moses_Isserles">Rema</a> who brings down the <a 1327 * href="http://en.wikipedia.org/wiki/Yaakov_ben_Moshe_Levi_Moelin">Maharil's</a> opinion of calculating it as 1328 * {@link #getSofZmanKidushLevanaBetweenMoldos() half way between <em>molad</em> and <em>molad</em>} is of the 1329 * opinion of the Mechaber as well. Also see the Aruch Hashulchan. For additional details on the subject, See Rabbi 1330 * Dovid Heber's very detailed writeup in Siman Daled (chapter 4) of <a 1331 * href="http://www.worldcat.org/oclc/461326125">Shaarei Zmanim</a>. This method returns the time even if it is during 1332 * the day when <em>Kiddush Levana</em> can't be said. Callers of this method should consider displaying <em>alos</em> 1333 * before this time if the <em>zman</em> is between <em>alos</em> and <em>tzais</em>. 1334 * 1335 * @return the Date representing the moment 15 days after the <em>molad</em>. 1336 * @see #getSofZmanKidushLevanaBetweenMoldos() 1337 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevana15Days() 1338 * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevana15Days(Date, Date) 1339 */ 1340 public Date getSofZmanKidushLevana15Days() { 1341 Date molad = getMoladAsDate(); 1342 Calendar cal = Calendar.getInstance(); 1343 cal.setTime(molad); 1344 cal.add(Calendar.HOUR, 24 * 15); //15 days after the molad. Add it as hours, not days, to avoid DST/ST crossover issues. 1345 return cal.getTime(); 1346 } 1347 1348 /** 1349 * Returns the <em>Daf Yomi (Bavli)</em> for the date that the calendar is set to. See the 1350 * {@link HebrewDateFormatter#formatDafYomiBavli(Daf)} for the ability to format the <em>daf</em> in 1351 * Hebrew or transliterated <em>masechta</em> names. 1352 * 1353 * @return the daf as a {@link Daf} 1354 */ 1355 public Daf getDafYomiBavli() { 1356 return YomiCalculator.getDafYomiBavli(this); 1357 } 1358 /** 1359 * Returns the <em>Daf Yomi (Yerushalmi)</em> for the date that the calendar is set to. See the 1360 * {@link HebrewDateFormatter#formatDafYomiYerushalmi(Daf)} for the ability to format the <em>daf</em> 1361 * in Hebrew or transliterated <em>masechta</em> names. 1362 * 1363 * @return the daf as a {@link Daf} 1364 */ 1365 public Daf getDafYomiYerushalmi() { 1366 return YerushalmiYomiCalculator.getDafYomiYerushalmi(this); 1367 } 1368 1369 /** 1370 * Returns the elapsed days since <em>Tekufas Tishrei</em>. This uses <em>Tekufas Shmuel</em> (identical to the <a href= 1371 * "https://en.wikipedia.org/wiki/Julian_year_(astronomy)">Julian Year</a> with a solar year length of 365.25 days). 1372 * The notation used below is D = days, H = hours and C = chalakim. <em><a href="https://en.wikipedia.org/wiki/Molad" 1373 * >Molad</a> BaHaRad</em> was 2D,5H,204C or 5H,204C from the start of <em>Rosh Hashana</em> year 1. For <em>molad 1374 * Nissan</em> add 177D, 4H and 438C (6 * 29D, 12H and 793C), or 177D,9H,642C after <em>Rosh Hashana</em> year 1. 1375 * <em>Tekufas Nissan</em> was 7D, 9H and 642C before <em>molad Nissan</em> according to the Rambam, or 170D, 0H and 1376 * 0C after <em>Rosh Hashana</em> year 1. <em>Tekufas Tishrei</em> was 182D and 3H (365.25 / 2) before <em>tekufas 1377 * Nissan</em>, or 12D and 15H before <em>Rosh Hashana</em> of year 1. Outside of Israel we start reciting <em>Tal 1378 * Umatar</em> in <em>Birkas Hashanim</em> from 60 days after <em>tekufas Tishrei</em>. The 60 days include the day of 1379 * the <em>tekufah</em> and the day we start reciting <em>Tal Umatar</em>. 60 days from the tekufah == 47D and 9H 1380 * from <em>Rosh Hashana</em> year 1. 1381 * 1382 * @return the number of elapsed days since <em>tekufas Tishrei</em>. 1383 * 1384 * @see #isVeseinTalUmatarStartDate() 1385 * @see #isVeseinTalUmatarStartingTonight() 1386 * @see #isVeseinTalUmatarRecited() 1387 */ 1388 public int getTekufasTishreiElapsedDays() { 1389 // Days since Rosh Hashana year 1. Add 1/2 day as the first tekufas tishrei was 9 hours into the day. This allows all 1390 // 4 years of the secular leap year cycle to share 47 days. Truncate 47D and 9H to 47D for simplicity. 1391 double days = getJewishCalendarElapsedDays(getJewishYear()) + (getDaysSinceStartOfJewishYear()-1) + 0.5; 1392 // days of completed solar years 1393 double solar = (getJewishYear() - 1) * 365.25; 1394 return (int) Math.floor(days - solar); 1395 } 1396 1397 /** 1398 * Returns if it is the Jewish day (starting the evening before) to start reciting <em>Vesein Tal Umatar 1399 * Livracha</em> (<em>Sheailas Geshamim</em>). In Israel this is the 7th day of <em>Marcheshvan</em>. Outside 1400 * Israel recitation starts on the evening of December 4th (or 5th if it is the year before a civil leap year) 1401 * in the 21st century and shifts a day forward every century not evenly divisible by 400. This method will 1402 * return true if <em>vesein tal umatar</em> on the current Jewish date that starts on the previous night, so 1403 * Dec 5/6 will be returned by this method in the 21st century. <em>vesein tal umatar</em> is not recited on 1404 * <em>Shabbos</em> and the start date will be delayed a day when the start day is on a <em>Shabbos</em> (this 1405 * can only occur out of Israel). 1406 * 1407 * @deprecated Use {@link TefilaRules#isVeseinTalUmatarStartDate(JewishCalendar)} instead. This method will be 1408 * removed in the v3.0 release. 1409 * 1410 * @return true if it is the first Jewish day (starting the prior evening of reciting <em>Vesein Tal Umatar 1411 * Livracha</em> (<em>Sheailas Geshamim</em>)). 1412 * 1413 * @see #isVeseinTalUmatarStartingTonight() 1414 * @see #isVeseinTalUmatarRecited() 1415 */ 1416 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1417 public boolean isVeseinTalUmatarStartDate() { 1418 if (inIsrael) { 1419 // The 7th Cheshvan can't occur on Shabbos, so always return true for 7 Cheshvan 1420 return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 7; 1421 } else { 1422 if (getDayOfWeek() == Calendar.SATURDAY) { //Not recited on Friday night 1423 return false; 1424 } 1425 if (getDayOfWeek() == Calendar.SUNDAY) { // When starting on Sunday, it can be the start date or delayed from Shabbos 1426 return getTekufasTishreiElapsedDays() == 48 || getTekufasTishreiElapsedDays() == 47; 1427 } else { 1428 return getTekufasTishreiElapsedDays() == 47; 1429 } 1430 } 1431 } 1432 1433 /** 1434 * Returns true if tonight is the first night to start reciting <em>Vesein Tal Umatar Livracha</em> ( 1435 * <em>Sheailas Geshamim</em>). In Israel this is the 7th day of <em>Marcheshvan</em> (so the 6th will return 1436 * true). Outside Israel recitation starts on the evening of December 4th (or 5th if it is the year before a 1437 * civil leap year) in the 21st century and shifts a day forward every century not evenly divisible by 400. 1438 * <em>Vesein tal umatar</em> is not recited on <em>Shabbos</em> and the start date will be delayed a day when 1439 * the start day is on a <em>Shabbos</em> (this can only occur out of Israel). 1440 * 1441 * @deprecated Use {@link TefilaRules#isVeseinTalUmatarStartingTonight(JewishCalendar)} instead. This method 1442 * will be removed in the v3.0 release. 1443 * 1444 * @return true if it is the first Jewish day (starting the prior evening of reciting <em>Vesein Tal Umatar 1445 * Livracha</em> (<em>Sheailas Geshamim</em>)). 1446 * 1447 * @see #isVeseinTalUmatarStartDate() 1448 * @see #isVeseinTalUmatarRecited() 1449 */ 1450 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1451 public boolean isVeseinTalUmatarStartingTonight() { 1452 if (inIsrael) { 1453 // The 7th Cheshvan can't occur on Shabbos, so always return true for 6 Cheshvan 1454 return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 6; 1455 } else { 1456 if (getDayOfWeek() == Calendar.FRIDAY) { //Not recited on Friday night 1457 return false; 1458 } 1459 if (getDayOfWeek() == Calendar.SATURDAY) { // When starting on motzai Shabbos, it can be the start date or delayed from Friday night 1460 return getTekufasTishreiElapsedDays() == 47 || getTekufasTishreiElapsedDays() == 46; 1461 } else { 1462 return getTekufasTishreiElapsedDays() == 46; 1463 } 1464 } 1465 } 1466 1467 /** 1468 * Returns if <em>Vesein Tal Umatar Livracha</em> (<em>Sheailas Geshamim</em>) is recited. This will return 1469 * true for the entire season, even on <em>Shabbos</em> when it is not recited. 1470 * 1471 * @deprecated Use {@link TefilaRules#isVeseinTalUmatarRecited(JewishCalendar)} instead. This method will 1472 * be removed in the v3.0 release. 1473 * 1474 * @return true if <em>Vesein Tal Umatar Livracha</em> (<em>Sheailas Geshamim</em>) is recited. 1475 * 1476 * @see #isVeseinTalUmatarStartDate() 1477 * @see #isVeseinTalUmatarStartingTonight() 1478 */ 1479 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1480 public boolean isVeseinTalUmatarRecited() { 1481 if (getJewishMonth() == NISSAN && getJewishDayOfMonth() < 15) { 1482 return true; 1483 } 1484 if (getJewishMonth() < CHESHVAN) { 1485 return false; 1486 } 1487 if (inIsrael) { 1488 return getJewishMonth() != CHESHVAN || getJewishDayOfMonth() >= 7; 1489 } else { 1490 return getTekufasTishreiElapsedDays() >= 47; 1491 } 1492 } 1493 1494 /** 1495 * Returns if <em>Vesein Beracha</em> is recited. It is recited from 15 <em>Nissan</em> to the point that {@link 1496 * #isVeseinTalUmatarRecited() <em>vesein tal umatar</em> is recited}. 1497 * 1498 * @deprecated Use {@link TefilaRules#isVeseinBerachaRecited(JewishCalendar)} instead. This method will be 1499 * removed in the v3.0 release. 1500 * 1501 * @return true if <em>Vesein Beracha</em> is recited. 1502 * 1503 * @see #isVeseinTalUmatarRecited() 1504 */ 1505 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1506 public boolean isVeseinBerachaRecited() { 1507 return !isVeseinTalUmatarRecited(); 1508 } 1509 1510 /** 1511 * Returns if the date is the start date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. The date is 22 <em>Tishrei</em>. 1512 * 1513 * @deprecated Use {@link TefilaRules#isMashivHaruachStartDate(JewishCalendar)} instead. This method will be 1514 * removed in the v3.0 release. 1515 * 1516 * @return true if the date is the start date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. 1517 * 1518 * @see #isMashivHaruachEndDate() 1519 * @see #isMashivHaruachRecited() 1520 */ 1521 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1522 public boolean isMashivHaruachStartDate() { 1523 return getJewishMonth() == TISHREI && getJewishDayOfMonth() == 22; 1524 } 1525 1526 /** 1527 * Returns if the date is the end date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. The date is 15 <em>Nissan</em>. 1528 * 1529 * @deprecated Use {@link TefilaRules#isMashivHaruachEndDate(JewishCalendar)} instead. This method will be 1530 * removed in the v3.0 release. 1531 * 1532 * @return true if the date is the end date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. 1533 * 1534 * @see #isMashivHaruachStartDate() 1535 * @see #isMashivHaruachRecited() 1536 */ 1537 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1538 public boolean isMashivHaruachEndDate() { 1539 return getJewishMonth() == NISSAN && getJewishDayOfMonth() == 15; 1540 } 1541 1542 /** 1543 * Returns if <em>Mashiv Haruach Umorid Hageshem</em> is recited. This period starts on 22 <em>Tishrei</em> and ends 1544 * on the 15th day of <em>Nissan</em>. 1545 * 1546 * @deprecated Use {@link TefilaRules#isMashivHaruachRecited(JewishCalendar)} instead. This method will be 1547 * removed in the v3.0 release. 1548 * 1549 * @return true if <em>Mashiv Haruach Umorid Hageshem</em> is recited. 1550 * 1551 * @see #isMashivHaruachStartDate() 1552 * @see #isMashivHaruachEndDate() 1553 */ 1554 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1555 public boolean isMashivHaruachRecited() { 1556 JewishDate startDate = new JewishDate(getJewishYear(), TISHREI, 22); 1557 JewishDate endDate = new JewishDate(getJewishYear(), NISSAN, 15); 1558 return compareTo(startDate) > 0 && compareTo(endDate) < 0; 1559 } 1560 1561 /** 1562 * Returns if <em>Morid Hatal</em> (or the lack of reciting <em>Mashiv Haruach</em> following <em>nussach Ashkenaz</em>) is recited. 1563 * This period starts on 22 <em>Tishrei</em> and ends on the 15th day of 1564 * <em>Nissan</em>. 1565 * 1566 * @deprecated Use {@link TefilaRules#isMoridHatalRecited(JewishCalendar)} instead. This method will be 1567 * removed in the v3.0 release. 1568 * 1569 * @return true if <em>Morid Hatal</em> (or the lack of reciting <em>Mashiv Haruach</em> following <em>nussach Ashkenaz</em>) is recited. 1570 */ 1571 @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version 1572 public boolean isMoridHatalRecited() { 1573 return !isMashivHaruachRecited() || isMashivHaruachStartDate() || isMashivHaruachEndDate(); 1574 } 1575 1576 /** 1577 * Returns true if the current day is <em>Isru Chag</em>. The method returns true for the day following <em>Pesach</em> 1578 * <em>Shavuos</em> and <em>Succos</em>. It utilizes {@see #getInIsrael()} to return the proper date. 1579 * 1580 * @return true if the current day is <em>Isru Chag</em>. The method returns true for the day following <em>Pesach</em> 1581 * <em>Shavuos</em> and <em>Succos</em>. It utilizes {@see #getInIsrael()} to return the proper date. 1582 */ 1583 public boolean isIsruChag() { 1584 int holidayIndex = getYomTovIndex(); 1585 return holidayIndex == ISRU_CHAG; 1586 } 1587 1588 /** 1589 * Indicates whether some other object is "equal to" this one. 1590 * @see Object#equals(Object) 1591 */ 1592 public boolean equals(Object object) { 1593 if (this == object) { 1594 return true; 1595 } 1596 if (!(object instanceof JewishCalendar)) { 1597 return false; 1598 } 1599 JewishCalendar jewishCalendar = (JewishCalendar) object; 1600 return getAbsDate() == jewishCalendar.getAbsDate() && getInIsrael() == jewishCalendar.getInIsrael(); 1601 } 1602 1603 /** 1604 * Overrides {@link Object#hashCode()}. 1605 * @see Object#hashCode() 1606 */ 1607 public int hashCode() { 1608 int result = 17; 1609 result = 37 * result + getClass().hashCode(); // needed or this and subclasses will return identical hash 1610 result += 37 * result + getAbsDate() + (getInIsrael() ? 1 : 3); 1611 return result; 1612 } 1613}