|
KosherJava Zmanim Homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.zmanim.hebrewcalendar.JewishDate
public class JewishDate
The JewishDate class allows one to maintain an instance of a Gregorian date along with the corresponding Jewish date. This class can use the standard Java Date and Calendar classes for setting it, but does not subclass these classes or use them internally to any extensive use. This class also does not have a concept of a time (which the Date class does). If you are looking for a class that implements a Jewish calendar version of the Calendar class, one is available from developerWorks by IBM. This open source Java code was written by Avrom Finkelstien from his C++ code. it was adapted to the KosherJava Zmanim API with simplification of the non-core code. The original algorithms were untouched. 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. The methods used to obtain the parsha were derived from the source code of HebCal by Danny Sadinoff and JCal for the Mac by Frank Yellin. Both based their code on routines by Nachum Dershowitz and Edward M. Reingold. The class allows setting whether the parsha and holiday scheme follows the Israel scheme or outside Israel scheme. TODO: Some do not belong in this class, but here is a partial list of what should still be implementted in some form:
Date
,
Calendar
Constructor Summary | |
---|---|
JewishDate()
Default constructor will set a default date to the current system date. |
|
JewishDate(Calendar calendar)
A constructor that initializes the date to the Calendar paremeter. |
|
JewishDate(Date date)
A constructor that initializes the date to the Date paremeter. |
|
JewishDate(int gregorianYear,
int gregorianMonth,
int gregorianDayOfMonth)
Creates a Jewish date based on a Gregorian date |
|
JewishDate(int gregorianYear,
int gregorianMonth,
int gregorianDayOfMonth,
boolean inIsrael)
Creates a Jewish date based on Gregorian date and whether in Israel |
Method Summary | |
---|---|
void |
back()
Rolls the date back by 1. |
Object |
clone()
Create a copy of this date. |
int |
compareTo(Object o)
Compares two dates as per the compareTo() method in the Comparable interface. |
boolean |
equals(Object object)
Compares two dates to see if they are equal |
void |
forward()
Rolls the date forward by 1. |
int |
getDayOfOmer()
Returns the int value of the Omer day or Integer.MIN_VALUE if the
day is not in the omer |
int |
getDayOfWeek()
Returns the day of the week as a number between 1-7. |
static int |
getDaysInJewishMonth(int month,
int year)
Returns the number of days of a Jewish month for a given month and year. |
int |
getGregorianDayOfMonth()
Returns the Gregorian day of the month. |
int |
getGregorianMonth()
Returns the Gregorian month (between 1-12). |
int |
getGregorianYear()
Returns the Gregotian year. |
String |
getHoliday()
Returns a String of the Jewish holiday or fast day for the current day, or a null if there is no holiday for this day. |
boolean |
getInIsrael()
Gets whether Israel parsha and holiday scheme is used or not. |
int |
getJewishDayOfMonth()
Returns the Jewish day of month. |
int |
getJewishMonth()
Returns the Jewish month (1-12 or 13). |
int |
getJewishYear()
Returns the Jewish year. |
(package private) int |
getLastDayOfGregorianMonth(int month)
Returns the number of days in a given month for the current year. |
String |
getParsha()
returns a string of today's parsha(ios) or an empty string if there are none. |
Date |
getTime()
Returns this object's date as a java.util.Date object. |
int |
hashCode()
|
static boolean |
isCheshvanLong(int year)
Returns if Cheshvan is long in a given Jewish year. |
static boolean |
isJewishLeapYear(int year)
Returns if the year is a Jewish leap year. |
static boolean |
isKislevShort(int year)
Returns if Kislev is short in a given Jewish year. |
boolean |
isRoshChodesh()
Returns if the day is Rosh Chodesh. |
void |
resetDate()
Resets this date to the current system date. |
void |
setDate(Calendar calendar)
Sets the date based on a Calendar object. |
void |
setDate(Date date)
Sets the date based on a Date object. |
void |
setGregorianDate(int year,
int month,
int dayOfMonth)
Sets the Gregorian Date, and updates the Jewish date accordingly. |
void |
setGregorianDayOfMonth(int dayOfMonth)
sets the Gregorian Day of month. |
void |
setGregorianMonth(int month)
Sets the Gregorian month. |
void |
setGregorianYear(int year)
sets the Gregorian year. |
void |
setInIsrael(boolean inIsrael)
Sets whether to use Israel parsha and holiday scheme or not. |
void |
setJewishDate(int year,
int month,
int dayOfMonth)
Sets the Jewish Date and updates the Gregorian date accordingly. |
void |
setJewishDayOfMonth(int dayOfMonth)
sets the Jewish day of month. |
void |
setJewishMonth(int month)
sets the Jewish month. |
void |
setJewishYear(int year)
sets the Jewish year. |
String |
toString()
Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729". |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JewishDate(int gregorianYear, int gregorianMonth, int gregorianDayOfMonth)
gregorianYear
- the Gregorian yeargregorianMonth
- the Gregorian month. Unlike the Java Calendar where January
has the value of 0,This expects a 1 for JanuarygregorianDayOfMonth
- the Gregorian day of month. If this is > the number of days in
the month/year, the last valid date of the month will be setpublic JewishDate(int gregorianYear, int gregorianMonth, int gregorianDayOfMonth, boolean inIsrael)
gregorianYear
- the Gregorian yeargregorianMonth
- the Gregorian month. Unlike the Java Calendar where January
has the value of 0,This expects a 1 for JanuarygregorianDayOfMonth
- the Gregorian day of month. If this is > the number of days in
the month/year, the last valid date of the month will be setinIsrael
- whether in Israel. This affects Yom Tov and Parsha
calculationspublic JewishDate()
public JewishDate(Date date)
Date
paremeter.
date
- the Date
to set the calendar topublic JewishDate(Calendar calendar)
Calendar
paremeter.
calendar
- the Calendar
to set the calendar toMethod Detail |
---|
int getLastDayOfGregorianMonth(int month)
month
- the month
public static boolean isJewishLeapYear(int year)
year
- the Jewish year.
public static boolean isCheshvanLong(int year)
year
- the year
public boolean isRoshChodesh()
public static boolean isKislevShort(int year)
year
- the Jewish year
public static int getDaysInJewishMonth(int month, int year)
month
- the Jewish monthyear
- the Jewish Year
public void setDate(Calendar calendar)
Calendar
object.
Modifies the Jewish date as well.
calendar
- the Calendar
to set the calendar topublic void setDate(Date date)
Date
object. Modifies the
Jewish date as well.
date
- the Date
to set the calendar topublic void setGregorianDate(int year, int month, int dayOfMonth)
year
- the Gregorian yearmonth
- the Gregorian month. Unlike the Java Calendar where January
has the value of 0,This expects a 1 for JanuarydayOfMonth
- the Gregorian day of month. If this is > the number of days in
the month/year, the last valid date of the month will be setpublic void setJewishDate(int year, int month, int dayOfMonth)
year
- the Jewish year. The year can't be negativemonth
- the Jewish month starting with Nisan. Nisan expects a value of
1 etc till Adar with a value of 12. For a leap year, 13 will
be the expected value for Adar II.dayOfMonth
- the Jewish day of month. valid values are 1-30. If the day of
month is set to 30 for a month that only has 29 days, the day
will be set as 29.public Date getTime()
Date
public void resetDate()
public String toString()
toString
in class Object
public void forward()
public void back()
public boolean equals(Object object)
equals
in class Object
public int compareTo(Object o)
compareTo
in interface Comparable
public int getGregorianMonth()
public int getGregorianDayOfMonth()
public int getGregorianYear()
public int getJewishMonth()
public int getJewishDayOfMonth()
public int getJewishYear()
public int getDayOfWeek()
public void setGregorianMonth(int month)
month
- the Gregorian monthpublic void setGregorianYear(int year)
year
- the Gregorian year.public void setGregorianDayOfMonth(int dayOfMonth)
dayOfMonth
- the Gregorian Day of month.public void setJewishMonth(int month)
month
- the Jewish month from 1 to 12 (or 13 years in a leap year).
The month count starts with 1 for Nisan and goes to 13 for
Adar IIpublic void setJewishYear(int year)
year
- the Jewish yearpublic void setJewishDayOfMonth(int dayOfMonth)
dayOfMonth
- the Jewish day of monthpublic int getDayOfOmer()
Integer.MIN_VALUE
if the
day is not in the omer
Integer.MIN_VALUE
if it is
not a day of the Omer.public String getHoliday()
public void setInIsrael(boolean inIsrael)
inIsrael
- set to true for calculations for Israelpublic boolean getInIsrael()
public String getParsha()
public Object clone()
clone
in class Object
public int hashCode()
hashCode
in class Object
Object.hashCode()
|
KosherJava Zmanim Homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |