Baal Hatanya’s Zmanim Added to KosherJava Zmanim Library

Baal Hatanya Zmanim (Photo With Hourglass)
While most calendars list the גר״א Gra and בעל התניא Baal Hatanya zmanim as identical, things are not that simple. Both are based on a day being from sunrise to sunset, but recently some Chabad calendars started using slightly different calculations for the Baal Hatanya’s zmanim. It should be noted that these zmanim are not universally accepted in Chabad (see the Opposing View section below). According to the Baal Hatanya in the סדר הכנסת שבת Seder Hachnasas Shabbos,

Seder Hachnasas Shabbos -Shkiah Amitis

מאד מאד צריך ליזהר בהדלקת נרות להדליק קודם שקיעת החמה, שקיעה הניראית, דהיינו בעוד השמש זורח בראשי האילנות בשדה בארץ המישור שאין שום הר במערב, או בראשי גגים הגבוהים בעיר, ולא לעשות אחר כך שום מלאכה כלל, כדי להוסיף מחול על הקודש מעט. כי אחר סילוק וביאת האור מראשי האילנות וגגים הגבוהים בכמו ד׳ חלקי ששיים משעה (שקורין מינוטין) אזי היא שקיעה האמיתית, שהוא סילוק וביאת האור מראשי ההרים הגבוהים שבארץ ישראל.

zmanim are calculated based on a 4 minute delay in shkiah. These 4 minutes are calculated as the sun’s position in degrees before sunrise and after sunset. While Chabad considers netz (also known as hanetz) as standard sunrise and shkiah as standard sunset, this is lechumra, and other zmanim are based on a slightly earlier sunrise and a slightly later sunset.

About 3 1/2 years ago, I posted information on calculating the Baal Hatanya’s Shkiah. That article was focused on a software developer’s perspective and explained how to use the existing API to calculate a fixed clock 4 minute zman that was not natively supported by the KosherJava zmanim library. Recently Yechiel Paricher contributed code to the KosherJava zmanim API/Library that added native support for various Baal Hatanya zmanim. This will enable users of the Zmanim library to easily include Baal Hatanya zmanim in their software.

According to the Baal Hatanya, shkiah amitis (true halachic sunset) is defined as:

כי אחר סילוק וביאת האור מראשי האילנות וגגים הגבוהים בכמו ד׳ חלקי ששיים משעה (שקורין מינוטין) אזי היא שקיעה האמיתית, שהוא סילוק וביאת האור מראשי ההרים הגבוהים שבארץ ישראל.

The time is calculated as the point at which the center of the sun’s disk is 1.583° below the horizon. Chabad applies the same degree based offset to netz amiti (true halachic sunrise). This degree based calculation can be found in Rabbi Shalom DovBer Levine’s commentary on The Baal Hatanya’s Seder Hachnasas Shabbos. From an elevation of 546 meters at the top of Har Hacarmel (based on the Gemara Shabbos 35a), the sun disappears at sunset when it is 1.583° (1° 35′) below the sea level horizon. There are other opinions that are not included in the code (but can easily be calculated using the API). One such example is a very similar (degree-wise) netz amiti from Rabbi Yosef Yitzchok Feigelstock. Rabbi Feigelstock calculates shkiah amitis as the degrees below the horizon 4 minutes after sunset in Yerushalaym (on the equinox). That degree based zman is listed in his letter to Rabbi Levine published in the back of the Seder Hachnasas Shabbos as 1.583°. The 1.583° is a typo (confirmed by Rabbi Feigelstock since it is identical to the 1° 35′ zman) and should be 1.683°. The calculations added to the KosherJava Zmanim library are used by most Chabad calendars that follow the Baal Hatanya’s Zmanim. See About Our Zmanim Calculations @ Chabad.org.

Zmanim based on shaos zmaniyos are based on a day between netz amiti and shkiah amitis calculated as 1.583° below the horizon. The various Baal Hatanya zmanim now part of the zmanim library include:

  • Alos 16.9° – based on the sun’s position below the horizon 72 minutes before netz amiti in Yerushayim around the equinox.
  • Sunrise or netz amiti – calculated as 1.583° below the horizon. This method is private and is only used as a base for other calculations.
  • Sof Zman Shma – calculated as 3 shaos zmaniyos (or a 1/4 of the day) after netz amiti.
  • Sof Zman Tfila – calculated as 4 shaos zmaniyos (or a 1/3 of the day) after netz amiti.
  • Sof Zman Achilas Chametz – calculated as 4 shaos zmaniyos (or a 1/3 of the day) after netz amiti.
  • Sof Zman Biur Chametz – calculated as 5 shaos zmaniyos after netz amiti.
  • Mincha Gedola – calculated as 6.5 shaos zmaniyos after netz amiti.
  • Mincha Gedola – Greater Than 30 – As above, but with a minimum 30 clock minutes after chatzos.
  • Mincha Ketana – calculated as 9.5 shaos zmaniyos after netz amiti.
  • Plag Hamincha – calculated as 10.75 shaos zmaniyos after netz amiti.
  • Sunset or shkiah amitis – calculated as 1.583° below the horizon. This method is private and is only used as a base for other calculations.
  • Tzais – calculated as the time when the sun is 6° below the western horizon. Note that as per Rabbi Yosef Yitzchok Feigelstock, for Motzai Shabbos, Motzai Yom Kippur and Motzai Yom Tov, the 8.5° time should be used. The time between 6° and 8.5° is part of tosfos Shabbos and tosfos Yom Kippur. Other zmanim such as zman krias shema can use the 6° zman. The 8.5° zman has always been part of the API, and sample code for calculating tzais 8.5° can be seen below.

These zmanim (not my implementation) that Chabad.org spent 2 years researching, have a haskama (endorsement) from Chabad Dayanim. Chabad.org zmanim do not provide seconds (appropriate due to expected refraction variances), but with the rounding rules provided by Rabbi Mordechai Sandhaus, the lead developer at Chabad.org, I was able to confirm that the Baal Hatanya zmanim generated by the KosherJava zmanim library match the Chabad.org times.

Please note that there are various Chabad shittos for netz, shkiah and tzais zmanim. The above are the commonly used ones. Other opinions on Baal Hatanya based zmanim that are less commonly used are not included in the API, but given the flexibility of the KosherJava Zmanim API they can easily be calculated.These include:

  • Netz Amiti 1.683° as calculated by Rabbi Feigelstock and mentioned above (only used for calculating other zmanim).
  • Shkiah Amitis 1.683° as calculated by Rabbi Feigelstock and mentioned above (only used for calculating other zmanim).
  • Tzais 5.833° as calculated by Rabbi Shalom DovBer Levine lekula for derabanans.
  • Tzais 6.3° as calculated by Rabbi Avrohom Altein, Chabad of Winnipeg, Manitoba, Canada.
  • Tzais 6.833° as calculated by Rabbi Shalom DovBer Levine lechumra for deoraysas.
  • Tzais 8.5° as commonly used by Chabad lechumra and mentioned above.

Code samples for these zmanim can be seen below.

Opposing Views

The relatively new calculations of zmanim based on netz amiti and shkiah amitis are not universally accepted in Chabad. Rabbi Avrohom Altein, the Rov of Chabad of Winnipeg, Manitoba, mentioned in a correspondence, that it is difficult to accept these new zmanim calculations as is.

The Alter Rebbe only speaks explicitly of shkiya amitis in regards to the beginning of Shabbos. We can draw comparisons to other areas of halacha but those comparisons needs to be carefully evaluated.
I believe that the Alter Rebbe does not calculate shaos zmaniyos based on netz & shkiya amitis, but rather on the standard netz & shkiya. There are several strong proofs to this. In earlier years, all of Chabad calculated shaos zmaniyos for laws of chometz, reading Shema etc., on the basis of standard sunrise and sunset and I believe that’s how the older Colel Chabad Luchos did the calculation. In recent years, this has changed in the Colel Chabad Luchos and chabad.org based on the opinion of Rabbi SDB Levin and Rabbi Feigeslstock — but there are Chabad rabbis that do not agree with their interpretation.

Code Samples

For developers, here is sample code that calculates the new zmanim. This should allow many zmanim apps to add Baal Hatanya zmanim with very little effort.

String locationName = "770 Eastern Parkway";
double latitude = 40.669;
double longitude = -73.943;
double elevation = 30;
TimeZone timeZone = TimeZone.getTimeZone("America/New_York");
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
ComplexZmanimCalendar czc = new ComplexZmanimCalendar(location);
czc.getCalendar().set(1994, Calendar.JUNE, 12);
System.out.println("Alos: " + czc.getAlosBaalHatanya()); //16.9 degrees
System.out.println("Sunrise: " + czc.getSunrise()); //standard sunrise
System.out.println("Sof Zman Shma: " + czc.getSofZmanShmaBaalHatanya());
System.out.println("Sof Zman Tfila: " + czc.getSofZmanTfilaBaalHatanya());
System.out.println("Sof Zman Achilas Chametz: " + czc.getSofZmanAchilasChametzBaalHatanya()); //only use on Erev Pesach
System.out.println("Sof Zman Biur Chametz: " + czc.getSofZmanBiurChametzBaalHatanya()); //only use on Erev Pesach
System.out.println("Mincha Gedola: " + czc.getMinchaGedolaBaalHatanya());
System.out.println("Mincha Gedola Min 30: " + czc.getMinchaGedolaBaalHatanyaGreaterThan30());
System.out.println("Mincha Ketana: " + czc.getMinchaKetanaBaalHatanya());
System.out.println("Plag Hamincha: " + czc.getPlagHaminchaBaalHatanya());
System.out.println("Sunset: " + czc.getSunset()); //standard sunset
System.out.println("Tzais Baal Hatanya: " + czc.getTzaisBaalHatanya()); //6° degrees
System.out.println("Tzais 8.5°: " + czc.getTzaisGeonim8Point5Degrees()); //8.5° degrees lechumra commonly used by Chabad
System.out.println("Shaah Zmanis Baal Hatanya: " + czc.getShaahZmanisBaalHatanya());

Calculating other Baal Hatanya based zmanim not included in the library are very simple. Here are a few examples

System.out.println("Netz Amiti 1.683°: " + czc.getSunriseOffsetByDegrees(90 + 1.683)); //Rabbi Feigelstock netz amiti (only used for calculating other zmanim)
System.out.println("Shkiah Amitis 1.683°: " + czc.getSunsetOffsetByDegrees(90 + 1.683)); //Rabbi Feigelstock shkiah amitis (only used for calculating other zmanim)
System.out.println("Tzais 5.833°: " + czc.getSunsetOffsetByDegrees(90 + 5.833)); //Rabbi Levine lekula for derabanans
System.out.println("Tzais 6.3°: " + czc.getSunsetOffsetByDegrees(90 + 6.3)); //Rabbi Avrohom Altein
System.out.println("Tzais 6.833°: " + czc.getSunsetOffsetByDegrees(90 + 6.833)); //Rabbi Levine lechumra for deoraysas

I would like to thank Rabbi Yosef Yitzchok Feigelstock, the Rov of Chabad in Buenos Aires, Rabbi Avrohom Altein, the Rov of Chabad in Winnipeg and Rabbi Mordechai Sandhaus, the lead developer at Chabad.org for reviewing this post.

FAQ: Different Parshas Hashavua in Eretz Yisrael Than Chutz La’aretz

KosherJava Zmanim API FAQ

Question:

Why does the KosherJava Zmanim API seem to sometimes return the incorrect parshas hashavua in Israel?

Answer:

I have had a number of inquiries this year about the incorrect Parshas Hashavua being returned by the API. In all cases this has been a complaint for Eretz Yisrael and not Chutz La’aretz. The explanation is pretty simple and covered in the API documentation for the JewishCalendar class, but may not be clear to all. When the first day of Pesach occurs on a Shabbos, as it did this year (5775), the last day of Pesach in Eretz Yisrael is on a Friday. The following day is a regular Shabbos in Eretz Yisrael with the usual krias hatorah, but in chutz la’aretz it is the 8th day of Pesach, resulting in krias Hatorah for Pesach. The following weeks will have different krias HaTorah in Eretz Yisrael vs chutz la’aretz, and this will continue for a number of weeks until a double parsha in chutz laaretz is added to equalize the parsha. This last occurred in 2012 (before the release of the calendar functionality in the Zmanim 1.3 release) and will occur again next year. If you are coding to display the Parshas Hashavuah for use in Israel, it is important to set the inIsrael(true) flag (it has a default of false).

JewishDate.setInIsrael(true);

A fuller example showing how to set the indicator and showing the comparison of Eretz Yisrael and Chutz Laaretz this year can be seen in this example.

JewishCalendar israelCalendar = new JewishCalendar(5775, JewishDate.NISSAN, 7);
israelCalendar.setInIsrael(true); //set the calendar to Israel
JewishCalendar chutsLaaretzCalendar = new JewishCalendar(5775, JewishDate.NISSAN, 7);
chutsLaaretzCalendar.setInIsrael(false); //not really needed since the API defaults to false
HebrewDateFormatter hdf = new HebrewDateFormatter();
System.out.println("Date\tChutz Laaretz / Eretz Yisrael"));
for(int i = 0; i < 57; i++){
	israelCalendar.forward(); //roll the date forward a day
	chutsLaaretzCalendar.forward(); //roll the date forward a day
	if(chutsLaaretzCalendar.getDayOfWeek() == 7){ //ignore weekdays
		System.out.println(hdf.formatParsha(chutsLaaretzCalendar) + "\t" + hdf.formatParsha(israelCalendar) + " \\ " + hdf.format(chutsLaaretzCalendar));
	}
}

the output of this is

Date               Chutz Laaretz / Eretz Yisrael
8 Nissan, 5775     Tzav / Tzav
15 Nissan, 5775     / 
22 Nissan, 5775     / Shmini
29 Nissan, 5775    Shmini / Tazria Metzora
6 Iyar, 5775       Tazria Metzora / Achrei Mos Kedoshim
13 Iyar, 5775      Achrei Mos Kedoshim / Emor
20 Iyar, 5775      Emor / Behar
27 Iyar, 5775      Behar Bechukosai / Bechukosai
5 Sivan, 5775      Bamidbar / Bamidbar

It should be noted that this discrepancy is not rare and happens about 25% of the calendar years.

FAQ: Calculating the Baal Hatanya’s Shkiah

Baal Hatanya Zmanim

Please see the more recent and updated article Baal Hatanya’s Zmanim Added to KosherJava Zmanim Library for more current information.

Question:

How do I calculate the בעל התניא Baal Hatanya’s Zman for Shkiah as 4 minutes after sunset using the KosherJava Zmanim API?

Answer:

I was recently asked how to use the Zmanim API to calculate the Baal Hatanya’s opinion is that shkiah (halachic sunset) is 4 minutes after civil sunset. The assumption that the Baal Hatanya’s shkiah is a fixed 4 minutes after sunset is not that simple and will require a separate post to clarify. This zman should not be used lehalacha without consulting a rov. This post shows how to us the API assuming that it is a fixed 4 minutes after sunset. The technique to calculate this with the API is identical to the way getTzais72() would be calculated. The source of that method is

public Date getTzais72() {
return getTimeOffset(getSeaLevelSunset(), 72 * MINUTE_MILLIS);
}

The getTimeOffset(Date time, double offset) method in the base class AstronomicalCalendar is very simple:

public Date getTimeOffset(Date time, long offset) {
if (time == null || offset == Long.MIN_VALUE) {
return null;
}
return new Date(time.getTime() + offset);
}

The getTimeOffset method simply adds the number of milliseconds of the offset to the raw time of the zman and returns it as a date. While using the API itself is not needed for such a simple calculation, here is how it would be used:

String locationName = "Jerusalem";
double latitude = 31.778; // Har habayis
double longitude = 35.2354;// Har Habayis
double elevation = 0;
TimeZone timeZone = TimeZone.getTimeZone("Asia/Jerusalem");
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
ZmanimCalendar zc = new ZmanimCalendar(location);
Date baalHatanyaShkiah = zc.getTimeOffset(zc.getSeaLevelSunset(), 4 * 60000);
System.out.println("Baal Hatanya Shkiah: " + baalHatanyaShkiah);

Adding it to the API itself would be even simpler:

public Date getShkiahBaalHatanya() {
return getTimeOffset(getSeaLevelSunset(), 4 * MINUTE_MILLIS);
}

At some point in the future I may (doubtful) add this time to the API itself. The zman is not commonly used, and the Chabad calendars that I have seen all use regular sunset.

Update on ‍‍July 5, 2015 – י״ח תמוז תשע״ה: This article was updated to clarify that the Baal Hatanya’s opinion may not be a fixed 4 minutes, but that the post was showing how to use the API to calculate it based on the questioner’s assumption that it was a 4 minute zman.
Update on Dec 14, 2018 – ו׳ טבת תשע״ט: This article was superseded with the more recent and corrected article Baal Hatanya’s Zmanim Added to KosherJava Zmanim Library.

Using the Zmanim API 1.3.0 Jewish Calendar Code

Sunrise CalendarThe recently released Zmanim API 1.3.0 added Jewish calendar support to the API. Previously, the API had zmanim support, but no Jewish calendar support. While the calendar code is in beta mode and is subject to API changes, below are some simple code examples using the current 1.3.0 release. These examples of the use of the JewishCalendar and HebrewDateFormatter classes do not fully cover the functionality available in the Zmanim API. Please read the JavaDocs and experiment. Please let me know if there are any calendar related items that you feel should change or be added to the API.

Setting and outputting formatted dates

JewishCalendar jd = new JewishCalendar(); // current date 23 Nissan, 5773
HebrewDateFormatter hdf = new HebrewDateFormatter();
System.out.println(jd); // prints hebrew date in English chars - 23 Nissan, 5773
hdf.setHebrewFormat(true); // change formatting to Hebrew
System.out.println(hdf.format(jd)); // date formatted in Hebrew
jd.setJewishDate(5729, JewishDate.SHEVAT, 21); // set the date to 21 Shevat, 5729
System.out.println(hdf.format(jd)); // date formatted in Hebrew
jd.setJewishDate(5772, JewishDate.NISSAN, 18); // set date to third day of Pesach
System.out.println(hdf.format(jd));
System.out.println(hdf.formatYomTov(jd)); //output Chol Hamoed Pesach in Hebrew
hdf.setHebrewFormat(false); // change formatting to default
System.out.println(hdf.format(jd)); // prints Hebrew date in English chars - 18 Nissan, 5772
System.out.println(hdf.formatYomTov(jd)); //output Chol Hamoed Pesach

Output:

23 Nissan, 5773
כ״ג ניסן תשע״ג
כ״א שבט תשכ״ט
י״ח ניסן תשע״ב
חול המועד פסח
18 Nissan, 5772
Chol Hamoed Pesach

Parshas Hashavua

Please note that the parsha will only input if the date is a Shabbos. This is something that may change down the line.

HebrewDateFormatter hdf = new HebrewDateFormatter();
JewishCalendar jd = new JewishCalendar(5773, JewishDate.NISSAN, 12);
System.out.println(hdf.formatParsha(jd));
hdf.setHebrewFormat(true);
System.out.println(hdf.formatParsha(jd));
jd.back();
System.out.println("Parsha on Friday [" + hdf.formatParsha(jd) + "]"); //no Parsha output on a non Shabbos
jd.setJewishDate(5773, JewishDate.TAMMUZ, 28); //double parsha
System.out.println(hdf.formatParsha(jd));

Output:

Tzav
צו
Parsha on Friday []
מטות מסעי

Rosh Chodesh

HebrewDateFormatter hdf = new HebrewDateFormatter();
JewishCalendar jd = new JewishCalendar(5773, JewishDate.NISSAN, 1);
if(jd.isRoshChodesh()){ //not necessary for formatter
	System.out.println(hdf.formatRoshChodesh(jd));
}
hdf.setHebrewFormat(true);
System.out.println(hdf.formatRoshChodesh(jd));
jd.forward();// roll calendar to second day of Nisan
System.out.println("output[" + hdf.formatRoshChodesh(jd) + "]"); //no output for Rosh Chodesh Formatting

Output:

Rosh Chodesh Nissan
ראש חודש ניסן
output[]

Daf Yomi

JewishCalendar jd = new JewishCalendar();
HebrewDateFormatter hdf = new HebrewDateFormatter();
System.out.println(hdf.format(jd)); //output current formatted date "13 Nissan, 5773"
Daf daf = jd.getDafYomiBavli(); //get the current daf
System.out.println(daf.getMasechtaTransliterated()); //outout transliterated masechta name "Eruvin"
System.out.println(daf.getDaf()); //output current daf (page) number "16"
System.out.println(hdf.formatDafYomiBavli(daf)); //outout the formatted date "Eruvin 16"
hdf.setHebrewFormat(true); //set formatted to Hebrew
System.out.println(hdf.format(jd)); //output date in Hebrew "י״ג ניסן תשע״ג"
System.out.println(daf.getMasechta()); // output masechta name in Hebrew "עירובין"
System.out.println(hdf.formatHebrewNumber(daf.getDaf()));//output the daf number formatted in Hebrew "ט״ז"
System.out.println(hdf.formatDafYomiBavli(daf)); //output daf and masechta in Hebrew "עירובין ט״ז"

Output:

13 Nissan, 5773
Eruvin
16
Eruvin 16
י״ג ניסן תשע״ג
עירובין
ט״ז
עירובין ט״ז

Chanukah

JewishCalendar jd = new JewishCalendar(5772, JewishDate.KISLEV, 25); //set date to first day of Chanukah
HebrewDateFormatter hdf = new HebrewDateFormatter();
System.out.println(jd);//output current transliterated date
System.out.println(jd.getDayOfChanukah()); //output #1
System.out.println(hdf.formatYomTov(jd)); //output Chanukah 1
hdf.setHebrewFormat(true); //set format to hebrew
System.out.println(hdf.formatHebrewNumber(jd.getDayOfChanukah())); //output 1 in Hebrew
System.out.println(hdf.formatYomTov(jd)); // output Chanukah 1 in hebrew

Output:

25 Kislev, 5772
1
Chanukah 1
א׳
א׳ חנוכה

Note, that there is no simple way at this point to output just Chanukah. This will likely change in the future to match Chanukah to the behavior of other Yomim Tovim.

Loop and output an entire year

JewishCalendar jc = new JewishCalendar(5773, JewishDate.TISHREI, 1);
jc.setInIsrael(false); //default false for clarity but not needed. Set to true for Israel
HebrewDateFormatter hdf = new HebrewDateFormatter();
hdf.setHebrewFormat(true);
HebrewDateFormatter hdfTransliterated = new HebrewDateFormatter();
String hebrewOutput = "";
String transliteratedOutput = "";
while(jc.getJewishYear() == 5773){
	hebrewOutput = hdf.format(jc);
	transliteratedOutput = hdfTransliterated.format(jc);
	if (jc.isYomTov() || jc.isTaanis()) {
		hebrewOutput += ", " + hdf.formatYomTov(jc);
		transliteratedOutput += ", " + hdfTransliterated.formatYomTov(jc);
	} else if(jc.getDayOfWeek() == 7){
		hebrewOutput += " - " + hdf.formatParsha(jc);
		transliteratedOutput += " - " + hdfTransliterated.formatParsha(jc);
	}
	if (jc.isChanukah()) {
		if (hebrewOutput.length() > 0) {
			hebrewOutput += ", ";
			transliteratedOutput += ", ";
		}
		hebrewOutput += hdf.formatYomTov(jc);
		transliteratedOutput  += hdfTransliterated.formatYomTov(jc);
	}
	if (jc.isRoshChodesh()) {
		if (hebrewOutput.length() > 0) {
			hebrewOutput += ", ";
			transliteratedOutput += ", ";
		}
		hebrewOutput += hdf.formatRoshChodesh(jc);
		transliteratedOutput += hdfTransliterated.formatRoshChodesh(jc);
	}
	if(jc.getDayOfOmer() > 0){
		hebrewOutput += ", ";
		transliteratedOutput += ", ";
		hebrewOutput += hdf.formatOmer(jc);
	}
	System.out.println(transliteratedOutput + " - " + hebrewOutput);
	jc.forward();
}

Output (most days removed for brevity):

1 Tishrei, 5773, Rosh Hashana - א׳ תשרי תשע״ג, ראש השנה
2 Tishrei, 5773, Rosh Hashana - ב׳ תשרי תשע״ג, ראש השנה
3 Tishrei, 5773, Fast of Gedalyah - ג׳ תשרי תשע״ג, צום גדליה
4 Tishrei, 5773 - ד׳ תשרי תשע״ג
...
6 Tishrei, 5773 - Vayeilech - ו׳ תשרי תשע״ג - וילך
...
10 Tishrei, 5773, Yom Kippur - י׳ תשרי תשע״ג, יום כיפור
...
15 Tishrei, 5773, Succos - ט״ו תשרי תשע״ג, סוכות
16 Tishrei, 5773, Succos - ט״ז תשרי תשע״ג, סוכות
17 Tishrei, 5773, Chol Hamoed Succos - י״ז תשרי תשע״ג, חול המועד סוכות
18 Tishrei, 5773, Chol Hamoed Succos - י״ח תשרי תשע״ג, חול המועד סוכות
19 Tishrei, 5773, Chol Hamoed Succos - י״ט תשרי תשע״ג, חול המועד סוכות
20 Tishrei, 5773, Chol Hamoed Succos - כ׳ תשרי תשע״ג, חול המועד סוכות
21 Tishrei, 5773, Hoshana Rabbah - כ״א תשרי תשע״ג, הושענא רבה
22 Tishrei, 5773, Shemini Atzeres - כ״ב תשרי תשע״ג, שמיני עצרת
23 Tishrei, 5773, Simchas Torah - כ״ג תשרי תשע״ג, שמחת תורה
...
30 Tishrei, 5773, Rosh Chodesh Cheshvan - ל׳ תשרי תשע״ג, ראש חודש חשוון
1 Cheshvan, 5773, Rosh Chodesh Cheshvan - א׳ חשוון תשע״ג, ראש חודש חשוון
...
25 Kislev, 5773, Chanukah 1 - כ״ה כסלו תשע״ג, א׳ חנוכה
26 Kislev, 5773, Chanukah 2 - כ״ו כסלו תשע״ג, ב׳ חנוכה
27 Kislev, 5773, Chanukah 3 - כ״ז כסלו תשע״ג, ג׳ חנוכה
28 Kislev, 5773, Chanukah 4 - כ״ח כסלו תשע״ג, ד׳ חנוכה
29 Kislev, 5773, Chanukah 5 - כ״ט כסלו תשע״ג, ה׳ חנוכה
1 Teves, 5773, Chanukah 6, Rosh Chodesh Teves - א׳ טבת תשע״ג, ו׳ חנוכה, ראש חודש טבת
2 Teves, 5773 - Miketz, Chanukah 7 - ב׳ טבת תשע״ג - מקץ, ז׳ חנוכה
3 Teves, 5773, Chanukah 8 - ג׳ טבת תשע״ג, ח׳ חנוכה
...
10 Teves, 5773, Tenth of Teves - י׳ טבת תשע״ג, עשרה בטבת
...
15 Shevat, 5773, Tu B'Shvat - ט״ו שבט תשע״ג, ט״ו בשבט
...
21 Shevat, 5773 - כ״א שבט תשע״ג
...
11 Adar, 5773, Fast of Esther - י״א אדר תשע״ג, תענית אסתר
...
14 Adar, 5773, Purim - י״ד אדר תשע״ג, פורים
15 Adar, 5773, Shushan Purim - ט״ו אדר תשע״ג, פורים שושן
...
27 Adar, 5773 - Vayakhel Pekudei - כ״ז אדר תשע״ג - ויקהל פקודי
...
15 Nissan, 5773, Pesach - ט״ו ניסן תשע״ג, פסח
16 Nissan, 5773, Pesach,  - ט״ז ניסן תשע״ג, פסח, א׳ בעומר
17 Nissan, 5773, Chol Hamoed Pesach,  - י״ז ניסן תשע״ג, חול המועד פסח, ב׳ בעומר
18 Nissan, 5773, Chol Hamoed Pesach,  - י״ח ניסן תשע״ג, חול המועד פסח, ג׳ בעומר
19 Nissan, 5773, Chol Hamoed Pesach,  - י״ט ניסן תשע״ג, חול המועד פסח, ד׳ בעומר
20 Nissan, 5773, Chol Hamoed Pesach,  - כ׳ ניסן תשע״ג, חול המועד פסח, ה׳ בעומר
21 Nissan, 5773, Pesach,  - כ״א ניסן תשע״ג, פסח, ו׳ בעומר
22 Nissan, 5773, Pesach,  - כ״ב ניסן תשע״ג, פסח, ז׳ בעומר
23 Nissan, 5773,  - כ״ג ניסן תשע״ג, ח׳ בעומר
...
26 Nissan, 5773 - Shmini,  - כ״ו ניסן תשע״ג - שמיני, י״א בעומר
...
6 Sivan, 5773, Shavuos - ו׳ סיוון תשע״ג, שבועות
7 Sivan, 5773, Shavuos - ז׳ סיוון תשע״ג, שבועות
...
17 Tammuz, 5773, Seventeenth of Tammuz - י״ז תמוז תשע״ג, שבעה עשר בתמוז
...
9 Av, 5773, Tishah B'Av - ט׳ אב תשע״ג, תשעה באב
...
15 Av, 5773, Tu B'Av - ט״ו אב תשע״ג, ט״ו באב
...

FAQ: Outputting Zmanim for A Different Time Zone With the Zmanim API

KosherJava Zmanim API FAQ

Question:

Why does the output of zmanim for a different time zone appear incorrect?

Answer:

One of the common issues encountered by developers using the API is that zmanim generated for a different time zone than the user’s time zone may return output that appears incorrect. For example a user in Lakewood, NJ trying to calculate sunrise for Yerushalayim may attempt to use the following code:

String locationName = "Jerusalem";
double latitude = 31.778; // Har habayis
double longitude = 35.2354;// Har Habayis
double elevation = 0;
TimeZone timeZone = TimeZone.getTimeZone("Asia/Jerusalem");
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
ZmanimCalendar zc = new ZmanimCalendar(location);
zc.getCalendar().set(2011, Calendar.FEBRUARY, 8);
System.out.println("Sunrise: " + zc.getSunrise());
System.out.println("Sunset: " + zc.getSunset());

While you would expect a sunrise of 6:27:41 AM and sunset of 5:19:19 PM, running this code on a computer anywhere in the Eastern Standard time zone would generate the following time that appears to be 7 hours early:

Sunrise: Mon Feb 07 23:27:41 EST 2011
Sunset: Tue Feb 08 10:19:19 EST 2011

The issue is simple, and the sunrise and sunset returned above are actually accurate. Zmanim are returned by the Zmanim API as a Java Date object that represents a moment in time (stored internally by Java as Unix Time – the number of milliseconds since the January 1, 1970 GMT). Sunrise in Yerushalayim on February 8th actually happens at 11:27:41 PM on February 7th EST. Java is simply outputting the Date as a String formatted to the users default time zone (EST in this example). The user probably intends to output the time in IST – Israel Standard Time (“Asia/Jerusalem” in the Olson database). To do this you have to output the zmanim using a formatter set to use the “Asia/Jerusalem” time zone.

DateFormat zmanimFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
zmanimFormat.setTimeZone(location.getTimeZone());

System.out.println("sunrise: " + zmanimFormat.format(zc.getSunrise()));
System.out.println("sunset:" + zmanimFormat.format(zc.getSunset()));

will output the expected

sunrise: Tue Feb 08 06:27:41 IST 2011
sunset:Tue Feb 08 17:19:19 IST 2011

Below is the full code example.

import com.kosherjava.zmanim.*;
import com.kosherjava.zmanim.util.*;
import java.util.TimeZone;
public class FormatZmanim{
	public static void main(String [] args) {
		String locationName = "Jerusalem";
		double latitude = 31.778; //latitude of Har habayis
		double longitude = 35.2354; //longitude of Har Habayis
		double elevation = 0; //optional elevation
		//use a Valid Olson Database timezone listed in java.util.TimeZone.getAvailableIDs()
		TimeZone timeZone = TimeZone.getTimeZone("Asia/Jerusalem");
		//create the location object
		GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
		ZmanimCalendar zc = new ZmanimCalendar(location); //create the ZmanimCalendar
		zc.getCalendar().set(2011, Calendar.FEBRUARY, 8); //set the date
		DateFormat zmanimFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); //Create the formatter
		zmanimFormat.setTimeZone(location.getTimeZone()); //set the formatter's time zone
		System.out.println("sunrise: " + zmanimFormat.format(zc.getSunrise()));
		System.out.println("sunset:" + zmanimFormat.format(zc.getSunset()));
	}
}