JewishCalendar

The JewishCalendar extends the JewishDate class and adds calendar methods.

This open source Java code was originally ported by Avrom Finkelstien from his C++ code. It was refactored to fit the KosherJava Zmanim API with simplification of the code, enhancements and some bug fixing. The class allows setting whether the holiday and parsha scheme follows the Israel scheme or outside Israel scheme. The default is the outside Israel scheme. The parsha code was ported by Y. Paritcher from his libzmanim code.

Author

Y. Paritcher 2019 - 2022

Avrom Finkelstien 2002

Eliyahu Hershfeld 2011 - 2023

See also

Date
java.util.Calendar

Constructors

Link copied to clipboard
constructor()

Default constructor will set a default date to the current system date.

constructor(date: Instant, tz: TimeZone)

A constructor that initializes the date to the Date parameter.

constructor(date: LocalDate)

A constructor that initializes the date to the date parameter.

constructor(date: HebrewLocalDate)

A constructor that initializes the hebrew date to the date parameter.

constructor(date: LocalDate, isInIsrael: Boolean)

A constructor that initializes the date to the date parameter.

constructor(date: LocalDate, isInIsrael: Boolean, shouldUseModernHolidays: Boolean)

A constructor that initializes the date to the date parameter.

constructor(date: HebrewLocalDate, isInIsrael: Boolean)

A constructor that initializes the hebrew date to the date parameter.

constructor(date: HebrewLocalDate, isInIsrael: Boolean, shouldUseModernHolidays: Boolean)

A constructor that initializes the heberew date to the date parameter.

constructor(jewishYear: Int, jewishMonth: Int, jewishDayOfMonth: Int)

Creates a Jewish date based on a Jewish year, month and day of month.

constructor(jewishYear: Long, jewishMonth: Int, jewishDayOfMonth: Int)
constructor(hebrewYear: Int, hebrewMonth: HebrewMonth, hebrewDayOfMonth: Int)
constructor(hebrewYear: Long, hebrewMonth: HebrewMonth, hebrewDayOfMonth: Int)
constructor(jewishYear: Int, jewishMonth: Int, jewishDayOfMonth: Int, inIsrael: Boolean)

Creates a Jewish date based on a Jewish date and whether in Israel

constructor(jewishYear: Long, jewishMonth: Int, jewishDayOfMonth: Int, inIsrael: Boolean)
constructor(jewishYear: Int, jewishMonth: HebrewMonth, jewishDayOfMonth: Int, inIsrael: Boolean)

Creates a Jewish date based on a Jewish date and whether in Israel

constructor(jewishYear: Long, jewishMonth: HebrewMonth, jewishDayOfMonth: Int, inIsrael: Boolean)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

List of parshiyos or special Shabasos. NONE indicates a week without a parsha, while the enum for the parsha of .VZOS_HABERACHA exists for consistency, but is not currently used. The special Shabasos of Shekalim, Zachor, Para, Hachodesh, as well as Shabbos Shuva, Shira, Hagadol, Chazon and Nachamu are also represented in this collection of parshiyos.

Properties

Link copied to clipboard

Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu to the Jewish year and month that this Object is set to.

Link copied to clipboard

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

Link copied to clipboard

Returns the Daf Yomi (Bavli) for the date that the LocalDate is set to. See the HebrewDateFormatter.formatDafYomiBavli for the ability to format the daf in Hebrew or transliterated masechta names.

Link copied to clipboard

Returns the Daf Yomi (Yerushalmi) for the date that the LocalDate is set to. See the HebrewDateFormatter.formatDafYomiYerushalmi for the ability to format the daf in Hebrew or transliterated masechta names.

Link copied to clipboard
val dayOfChanukah: Int

Returns the day of Chanukah or -1 if it is not Chanukah.

Link copied to clipboard
val dayOfOmer: Int

Returns the int value of the Omer day or -1 if the day is not in the Omer.

Link copied to clipboard

Returns the number of days of the Jewish month that the calendar is currently set to.

Link copied to clipboard

Returns the number of days for the current year that the calendar is set to.

Link copied to clipboard

returns the number of days from Rosh Hashana of the date passed in, to the full date passed in.

Link copied to clipboard
Link copied to clipboard
lateinit var gregorianLocalDate: LocalDate
Link copied to clipboard
Link copied to clipboard
var gregorianYear: Int
Link copied to clipboard
val hasCandleLighting: Boolean

Returns true if the day has candle lighting. This will return true on Erev Shabbos, Erev Yom Tov, the first day of Rosh Hashana and the first days of Yom Tov out of Israel. It is identical to calling isTomorrowShabbosOrYomTov.

Link copied to clipboard

Returns this object's date as a LocalDate object.

Link copied to clipboard
var inIsrael: Boolean

Is the calendar set to Israel, where some holidays have different rules.

Link copied to clipboard

Returns true if the current day is Aseres Yemei Teshuva.

Link copied to clipboard
val isAssurBemelacha: Boolean

Returns true if it is Shabbos or if it is a Yom Tov day that has a melacha (work) prohibition.

Link copied to clipboard
val isBeHaB: Boolean

The Monday, Thursday and Monday after the first Shabbos after Rosh Chodesh Cheshvan and Iyar are BeHaB days. If the last Monday of Iyar's BeHaB coincides with PESACH_SHENI, the method currently considers it both Pesach Sheni and BeHaB. As seen in an Ohr Sameach article on the subject The unknown Days: BeHaB Vs. Pesach Sheini? there are some customs that delay the day to various points in the future.

Link copied to clipboard
val isBirkasHachamah: Boolean

Birkas Hachamah is recited every 28 years based on Tekufas Shmuel (Julian years) that a year is 365.25 days. The Rambam in &&Hilchos Kiddush Hachodesh 9:3 states that tekufas Nissan of year 1 was 7 days + 9 hours before molad Nissan. This is calculated as every 10,227 days (28 * 365.25).

Link copied to clipboard
val isChanukah: Boolean

Returns true if the current day is one of the 8 days of Chanukah.

Link copied to clipboard
val isCheshvanLong: Boolean

Returns if Cheshvan is long (30 days VS 29 days) for the current year that the calendar is set to. The method name isLong is done since in a Kesidran (ordered) year Cheshvan is short.

Link copied to clipboard
val isCholHamoed: Boolean

Returns true if the current day is Chol Hamoed of Pesach or Succos.

Link copied to clipboard
val isCholHamoedPesach: Boolean

Returns true if the current day is Chol Hamoed of Pesach.

Link copied to clipboard
val isCholHamoedSuccos: Boolean

Returns true if the current day is Chol Hamoed of Succos.

Link copied to clipboard
val isErevPesach: Boolean
Link copied to clipboard
val isErevRoshChodesh: Boolean

Returns true if the current day is Erev Rosh Chodesh. Returns false for Erev Rosh Hashana.

Link copied to clipboard
val isErevRoshHashana: Boolean
Link copied to clipboard
val isErevShavuos: Boolean
Link copied to clipboard
Link copied to clipboard
val isErevSuccos: Boolean
Link copied to clipboard
val isErevYomKippur: Boolean
Link copied to clipboard
val isErevYomTov: Boolean

Returns true if the current day is Erev Yom Tov. The method returns true for Erev - Pesach (first and last days), Shavuos, Rosh Hashana, Yom Kippur, Succos and Hoshana Rabba.

Link copied to clipboard
val isErevYomTovSheni: Boolean

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

Link copied to clipboard
val isHoshanaRabba: Boolean

Returns true if the current day is Hoshana Rabba.

Link copied to clipboard
val isIsruChag: Boolean

Returns true if the current day is Isru Chag. The method returns true for the day following Pesach Shavuos and Succos. It utilizes {@see #inIsrael} to return the proper date.

Link copied to clipboard
val isJewishLeapYear: Boolean

Returns if the year the calendar is set to is a Jewish leap year. Years 3, 6, 8, 11, 14, 17 and 19 in the 19 year cycle are leap years.

Link copied to clipboard
val isKislevShort: Boolean

Returns if the Kislev is short for the year that this class is set to. The method name isShort is done since in a Kesidran (ordered) year Kislev is long.

Link copied to clipboard
val isMacharChodesh: Boolean

Returns if the day is Shabbos and Sunday is Rosh Chodesh and the haftorah of Machar Chodesh is read.

Link copied to clipboard
var isMukafChoma: Boolean

Is the calendar set to have Purim demukafim, where Purim is celebrated on Shushan Purim.

Link copied to clipboard
val isPesach: Boolean

Returns true if the current day is Pesach (either the Yom Tov of Pesach orChol Hamoed Pesach).

Link copied to clipboard
val isPurim: Boolean

Returns if the day is Purim (Shushan Purim in a mukaf choma and regular Purim in a non-mukaf choma).

Link copied to clipboard
val isRoshChodesh: Boolean

Returns if the day is Rosh Chodesh. Rosh Hashana will return false

Link copied to clipboard
val isRoshHashana: Boolean

Returns true if the current day is Rosh Hashana.

Link copied to clipboard
val isShabbosMevorchim: Boolean

Returns if the day is Shabbos Mevorchim.

Link copied to clipboard
val isShavuos: Boolean

Returns true if the current day is Shavuos.

Link copied to clipboard
val isShminiAtzeres: Boolean

Returns true if the current day is Shmini Atzeres.

Link copied to clipboard
val isSimchasTorah: Boolean

Returns true if the current day is Simchas Torah. This will always return false if .getInIsrael

Link copied to clipboard
val isSuccos: Boolean

Returns true if the current day is Succos (either the Yom Tov of Succos orChol Hamoed Succos). It will return false for Shmini Atzeres and Simchas Torah.

Link copied to clipboard
val isTaanis: Boolean

Return true if the day is a Taanis (fast day). Return true for 17 of Tammuz, Tisha B'Av, Yom Kippur, Fast of Gedalyah, 10 of Teves and the Fast of Esther.

Link copied to clipboard
val isTaanisBechoros: Boolean

Return true if the day is Taanis Bechoros (on Erev Pesach). It will return true for the 14th of Nissan if it is not on Shabbos, or if the 12th of Nissan occurs on a Thursday.

Link copied to clipboard
val isTishaBav: Boolean

Returns if the day is Tisha Be'Av (the 9th of Av).

Link copied to clipboard

Returns true if tomorrow is Shabbos or Yom Tov. This will return true on Erev Shabbos, Erev Yom Tov, the first day of Rosh Hashana and erev the first days of Yom Tov out of Israel. It is identical to calling hasCandleLighting.

Link copied to clipboard
var isUseModernHolidays: Boolean

Is the calendar set to use modern Israeli holidays such as Yom Haatzmaut.

Link copied to clipboard
val isYomKippur: Boolean

Returns true if the current day is Yom Kippur.

Link copied to clipboard
val isYomKippurKatan: Boolean

Returns true if the current day is Yom Kippur Katan. Returns false for Erev Rosh Hashana, Erev Rosh Chodesh Cheshvan, Teves and Iyyar. If Erev Rosh Chodesh occurs on a Friday or Shabbos, Yom Kippur Katan is moved back to Thursday.

Link copied to clipboard
val isYomTov: Boolean

Returns true if the current day is Yom Tov. The method returns true even for holidays such as CHANUKAH and minor ones such as TU_BEAV and PESACH_SHENI. Erev Yom Tov (with the exception of HOSHANA_RABBA, erev the second days of PESACH) returns false, as do fast besides YOM_KIPPUR. Use isAssurBemelacha to find the days that have a prohibition of work.

Link copied to clipboard

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

Link copied to clipboard

The Jewish day of month.

Link copied to clipboard
Link copied to clipboard
var jewishYear: Long
Link copied to clipboard
Link copied to clipboard

Returns the molad for a given year and month. Returns a JewishDate Object set to the date of the molad with the hours, minutes and chalakim set. In the current implementation, it sets the molad time based on a midnight date rollover. This means that Rosh Chodesh Adar II, 5771 with a molad of 7 chalakim past midnight on Shabbos 29 Adar I / March 5, 2011 12:00 AM and 7 chalakim, will have the following values: hours: 0, minutes: 0, Chalakim: 7.

Link copied to clipboard
val moladAsInstant: Instant

Returns the molad in Standard Time in Yerushalayim as a Date. The traditional calculation uses local time. This method subtracts 20.94 minutes (20 minutes and 56.496 seconds) from the local time (of Har Habayis with a longitude of 35.2354 is 5.2354 away from the %15 timezone longitude) to get to standard time. This method intentionally uses standard time and not daylight savings time. Java (TODO correct for Kotlin) will implicitly format the time to the default (or set) Timezone.

Link copied to clipboard
var moladChalakim: Int

the internal count of molad chalakim / parts. Only an object populated with molad, setJewishDate or moladChalakim will have these fields populated. A regular JewishDate object will have this field set to 0.

Link copied to clipboard
var moladHours: Int

The molad hours. Only a JewishDate object populated with molad, setJewishDate or moladHours will have this field populated. A regular JewishDate object will have this field set to 0.

Link copied to clipboard
var moladMinutes: Int

The molad minutes. Only an object populated with molad, setJewishDate or moladMinutes will have these fields populated. A regular JewishDate object will have this field set to 0.

Link copied to clipboard

Returns this week's Parsha if it is Shabbos. It returns Parsha.NONE if the date is a weekday or if there is no parsha that week (for example Yom Tov that falls on a Shabbos).

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

Returns a Parsha enum if the Shabbos is one of the four parshiyos of Parsha.SHKALIM, Zachor, Para, Parsha.HACHODESH or Parsha.NONE for a regular Shabbos (or any weekday).

Link copied to clipboard

Returns the earliest time of Kiddush Levana calculated as 3 days after the molad. This method returns the time even if it is during the day when Kiddush Levana can't be said. Callers of this method should consider displaying the next tzais if the zman is between alos and tzais.

Link copied to clipboard

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

Link copied to clipboard

Returns the elapsed days since Tekufas Tishrei. This uses Tekufas Shmuel (identical to the Julian Year with a solar year length of 365.25 days). The notation used below is D = days, H = hours and C = chalakim. Molad BaHaRad was 2D,5H,204C or 5H,204C from the start of Rosh Hashana year 1. For molad Nissan add 177D, 4H and 438C (6 * 29D, 12H and 793C), or 177D,9H,642C after Rosh Hashana year 1. Tekufas Nissan was 7D, 9H and 642C before molad Nissan according to the Rambam, or 170D, 0H and 0C after Rosh Hashana year 1. Tekufas Tishrei was 182D and 3H (365.25 / 2) before tekufas Nissan, or 12D and 15H before Rosh Hashana of year 1. Outside of Israel we start reciting Tal Umatar in Birkas Hashanim from 60 days after tekufas Tishrei. The 60 days include the day of the tekufah and the day we start reciting Tal Umatar. 60 days from the tekufah == 47D and 9H from Rosh Hashana year 1.

Link copied to clipboard

Returns the upcoming Parsha regardless of if it is the weekday or Shabbos (where next Shabbos's Parsha will be returned. This is unlike .getParshah that returns Parsha.NONE if the date is not Shabbos. If the upcoming Shabbos is a Yom Tov and has no Parsha, the following week's Parsha will be returned.

Link copied to clipboard
val yomTovIndex: Int

Returns an index of the Jewish holiday or fast day for the current day, or a -1 if there is no holiday for this day. There are constants in this class representing each Yom Tov. Formatting of the Yomim tovim is done in the HebrewDateFormatter.formatYomTov.

Functions

Link copied to clipboard

Rolls the date back by 1 day. It modifies both the Gregorian and Jewish dates accordingly. The API does not currently offer the ability to forward more than one day at a time, or to forward by month or year. If such manipulation is required use the java.util.Calendar class java.util.Calendar.add or java.util.Calendar.roll methods in the following manner.

Link copied to clipboard
open operator override fun compareTo(other: JewishDate): Int

Compares two dates as per the compareTo() method in the Comparable interface. Returns a value less than 0 if this date is "less than" (before) the date, greater than 0 if this date is "greater than" (after) the date, or 0 if they are equal.

Link copied to clipboard
fun copy(jewishYear: Long = this.hebrewLocalDate.year, jewishMonth: HebrewMonth = this.hebrewLocalDate.month, jewishDayOfMonth: Int = this.jewishDayOfMonth, inIsrael: Boolean = this.inIsrael): JewishCalendar
fun copy(jewishYear: Long = this.hebrewLocalDate.year, jewishMonth: Int = this.hebrewLocalDate.month.value, jewishDayOfMonth: Int = this.jewishDayOfMonth, inIsrael: Boolean = this.inIsrael): JewishCalendar

fun copy(hebrewYear: Long = hebrewLocalDate.year, month: HebrewMonth = hebrewLocalDate.month, hebrewDayOfMonth: Int = hebrewLocalDate.dayOfMonth): JewishDate

A method that creates a deep copy of the object.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

Link copied to clipboard
fun forward(field: DateTimeUnit, amount: Int): JewishDate

Rolls the date, month or year forward by the amount passed in. It modifies both the Gregorian and Jewish dates accordingly. If manipulation beyond the fields supported here is required, use the Calendar class Calendar.add or Calendar.roll methods in the following manner.

Link copied to clipboard
open override fun hashCode(): Int

Overrides Object.hashCode.

Link copied to clipboard

Resets this date to the current system date.

Link copied to clipboard
fun setDate(date: LocalDate): JewishDate

Sets the date based on a LocalDateTime object. Modifies the Jewish date as well.

Link copied to clipboard
fun setGregorianDate(year: Int, month: Int, dayOfMonth: Int): JewishDate

Sets the Gregorian Date, and updates the Jewish date accordingly. Like the Java Calendar A value of 0 is expected for January.

Link copied to clipboard
fun setJewishDate(year: Long, month: HebrewMonth, dayOfMonth: Int, hours: Int, minutes: Int, chalakim: Int): JewishDate

Sets the Jewish Date and updates the Gregorian date accordingly.

fun setJewishDate(year: Long, month: HebrewMonth, dayOfMonth: Int): JewishDate
Link copied to clipboard

sets the Jewish month.

Link copied to clipboard
open override fun toString(): String

Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729". For more complex formatting, use the formatter classes.