JewishDate

open class JewishDate : Comparable<JewishDate>

The JewishDate is the base calendar class, that supports maintenance of a LocalDateTime instance along with the corresponding Jewish date. This class can use the standard Java (TODO change for kotlin) Date and Calendar classes for setting and maintaining the dates, but it does not subclass these classes or use them internally in any calculations. This class also does not have a concept of a time (which the Date class does). Please note that the calendar does not currently support dates prior to 1/1/1 Gregorian. Also keep in mind that the Gregorian calendar started on October 15, 1582, so any calculations prior to that are suspect (at least from a Gregorian perspective). While 1/1/1 Gregorian and forward are technically supported, any calculations prior to Hillel II's (Hakatan's) calendar (4119 in the Jewish Calendar / 359 CE Julian as recorded by Rav Hai Gaon) would be just an approximation.

This open source Java code was written by Avrom Finkelstien from his C++ code. It was refactored to fit the KosherJava Zmanim API with simplification of the code, enhancements and some bug fixing.

Some of Avrom's original C++ code was translated from C/C++ code in Calendrical Calculations by Nachum Dershowitz and Edward M. Reingold, Software-- Practice & Experience, vol. 20, no. 9 (September, 1990), pp. 899- 928. Any method with the mark "ND+ER" indicates that the method was taken from this source with minor modifications.

If you are looking for a class that implements a Jewish calendar version of the Calendar class, one is available from the ICU (International Components for Unicode) project, formerly part of IBM's DeveloperWorks.

Author

Avrom Finkelstien 2002

Eliyahu Hershfeld 2011 - 2021

See also

Date
java.util.Calendar

Inheritors

Constructors

Link copied to clipboard
constructor(molad: Long)

Constructor that creates a JewishDate based on a molad passed in. The molad would be the number of chalakim/parts starting at the beginning of Sunday prior to the molad Tohu BeHaRaD (Be = Monday, Ha= 5 hours and Rad =204 chalakim/parts) - prior to the start of the Jewish calendar. BeHaRaD is 23:11:20 on Sunday night(5 hours 204/1080 chalakim after sunset on Sunday evening).

constructor(hebrewYear: Int, hebrewMonth: HebrewMonth, hebrewDayOfMonth: Int)

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

constructor(hebrewYear: Long, hebrewMonth: HebrewMonth, hebrewDayOfMonth: Int)
constructor(hebrewYear: Int, hebrewMonth: Int, hebrewDayOfMonth: Int)
constructor(localDate: LocalDate)
constructor(hebrewLocalDate: HebrewLocalDate)
constructor()

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

Types

Link copied to clipboard
object Companion

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

Returns this object's date as a LocalDate object.

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

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

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