From db828933f132bc51ae426f3e70437205dcf4283c Mon Sep 17 00:00:00 2001 From: KosherJava Date: Thu, 1 Aug 2024 21:37:34 -0400 Subject: [PATCH] JewishDate.java documentation-only tweaks - Correct one instance of TRaD to TUTaKPaT (thanks Shai) - Minor spelling changes - Add many tags --- .../zmanim/hebrewcalendar/JewishDate.java | 246 ++++++++---------- 1 file changed, 113 insertions(+), 133 deletions(-) diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java index e38af3e8..673b28d6 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java @@ -1,6 +1,6 @@ /* * Zmanim Java API - * Copyright (C) 2011 - 2021 Eliyahu Hershfeld + * Copyright (C) 2011 - 2024 Eliyahu Hershfeld * Copyright (C) September 2002 Avrom Finkelstien * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General @@ -32,17 +32,17 @@ * href="http://en.wikipedia.org/wiki/Hillel_II">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 + * 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. @@ -52,7 +52,7 @@ * @see java.util.Date * @see java.util.Calendar * @author © Avrom Finkelstien 2002 - * @author © Eliyahu Hershfeld 2011 - 2021 + * @author © Eliyahu Hershfeld 2011 - 2024 */ public class JewishDate implements Comparable, Cloneable { /** @@ -144,7 +144,7 @@ public class JewishDate implements Comparable, Cloneable { /** * the Jewish epoch using the RD (Rata Die/Fixed Date or Reingold Dershowitz) day used in Calendrical Calculations. - * Day 1 is January 1, 0001, Gregorian + * Day 1 is January 1, 0001 of the Gregorian calendar */ private static final int JEWISH_EPOCH = -1373429; @@ -158,8 +158,8 @@ public class JewishDate implements Comparable, Cloneable { * chalakim (44 minutes and 3.3 seconds) for a total of 765,433 chalakim*/ private static final long CHALAKIM_PER_MONTH = 765433; // (29 * 24 + 12) * 1080 + 793 /** - * Days from the beginning of Sunday till molad BaHaRaD. Calculated as 1 day, 5 hours and 204 chalakim = (24 + 5) * - * 1080 + 204 = 31524 + * Days from the beginning of Sunday till molad BaHaRaD. Calculated as 1 day, 5 hours and 204 chalakim = + * (24 + 5) * 1080 + 204 = 31524 */ private static final int CHALAKIM_MOLAD_TOHU = 31524; @@ -197,15 +197,15 @@ public class JewishDate implements Comparable, Cloneable { private int moladHours; /** the internal count of molad minutes.*/ private int moladMinutes; - /** the internal count of molad chalakim.*/ + /** the internal count of molad chalakim.*/ private int moladChalakim; /** - * Returns the molad hours. Only a JewishDate object populated with {@link #getMolad()}, + * Returns the molad hours. Only a JewishDate object populated with {@link #getMolad()}, * {@link #setJewishDate(int, int, int, int, int, int)} or {@link #setMoladHours(int)} will have this field * populated. A regular JewishDate object will have this field set to 0. * - * @return the molad hours + * @return the molad hours * @see #setMoladHours(int) * @see #getMolad() * @see #setJewishDate(int, int, int, int, int, int) @@ -215,10 +215,10 @@ public int getMoladHours() { } /** - * Sets the molad hours. + * Sets the molad hours. * * @param moladHours - * the molad hours to set + * the molad hours to set * @see #getMoladHours() * @see #getMolad() * @see #setJewishDate(int, int, int, int, int, int) @@ -229,11 +229,11 @@ public void setMoladHours(int moladHours) { } /** - * Returns the molad minutes. Only an object populated with {@link #getMolad()}, + * Returns the molad minutes. Only an object populated with {@link #getMolad()}, * {@link #setJewishDate(int, int, int, int, int, int)} or or {@link #setMoladMinutes(int)} will have these fields * populated. A regular JewishDate object will have this field set to 0. * - * @return the molad minutes + * @return the molad minutes * @see #setMoladMinutes(int) * @see #getMolad() * @see #setJewishDate(int, int, int, int, int, int) @@ -243,9 +243,9 @@ public int getMoladMinutes() { } /** - * Sets the molad minutes. The expectation is that the traditional minute-less chalakim will be broken out to - * minutes and {@link #setMoladChalakim(int) chalakim/parts} , so 793 (TaShTZaG) parts would have the minutes set to - * 44 and chalakim to 1. + * Sets the molad minutes. The expectation is that the traditional minute-less chalakim will be broken out to + * minutes and {@link #setMoladChalakim(int) chalakim / parts} , so 793 (TaShTZaG) parts would have the minutes set to + * 44 and chalakim to 1. * * @param moladMinutes * the molad minutes to set @@ -260,12 +260,12 @@ public void setMoladMinutes(int moladMinutes) { } /** - * Sets the molad chalakim/parts. The expectation is that the traditional minute-less chalakim will be broken out to - * {@link #setMoladMinutes(int) minutes} and chalakim, so 793 (TaShTZaG) parts would have the minutes set to 44 and - * chalakim to 1. + * Sets the molad chalakim/parts. The expectation is that the traditional minute-less chalakim will be broken + * out to {@link #setMoladMinutes(int) minutes} and chalakim, so 793 (TaShTZaG) parts would have the minutes set to 44 and + * chalakim to 1. * * @param moladChalakim - * the molad chalakim/parts to set + * the molad chalakim / parts to set * @see #getMoladChalakim() * @see #setMoladMinutes(int) * @see #getMolad() @@ -277,11 +277,11 @@ public void setMoladChalakim(int moladChalakim) { } /** - * Returns the molad chalakim/parts. Only an object populated with {@link #getMolad()}, + * Returns the molad chalakim / parts. Only an object populated with {@link #getMolad()}, * {@link #setJewishDate(int, int, int, int, int, int)} or or {@link #setMoladChalakim(int)} will have these fields * populated. A regular JewishDate object will have this field set to 0. * - * @return the molad chalakim/parts + * @return the molad chalakim / parts * @see #setMoladChalakim(int) * @see #getMolad() * @see #setJewishDate(int, int, int, int, int, int) @@ -312,8 +312,8 @@ boolean isGregorianLeapYear(int year) { } /** - * The month, where 1 == January, 2 == February, etc... Note that this is different from Java's Calendar class - * where January == 0 + * The month, where 1 == January, 2 == February, etc... Note that this is different than Java's Calendar class + * where January == 0. */ private int gregorianMonth; @@ -326,7 +326,7 @@ boolean isGregorianLeapYear(int year) { /** 1 == Sunday, 2 == Monday, etc... */ private int dayOfWeek; - /** Returns the absolute date (days since January 1, 0001, on the Gregorian calendar). + /** Returns the absolute date (days since January 1, 0001 of the Gregorian calendar). * @see #getAbsDate() * @see #absDateToJewishDate() */ @@ -379,7 +379,7 @@ private void absDateToDate(int absDate) { } /** - * Returns the absolute date (days since January 1, 0001, on the Gregorian calendar). + * Returns the absolute date (days since January 1, 0001 of the Gregorian calendar). * * @return the number of days since January 1, 1 */ @@ -453,10 +453,10 @@ private static int getLastMonthOfJewishYear(int year) { * * @param year * the Jewish year - * @return the number of days elapsed from prior to the molad Tohu BaHaRaD (Be = Monday, Ha= 5 hours and Rad =204 - * chalakim/parts) prior to the start of the Jewish calendar, to the mean conjunction of Tishri of the - * Jewish year. BeHaRaD is 23:11:20 on Sunday night(5 hours 204/1080 chalakim after sunset on Sunday - * evening). + * @return the number of days elapsed from prior to the molad Tohu BaHaRaD (Be = Monday, Ha = 5 + * hours and RaD = 204 chalakim / parts) prior to the start of the Jewish calendar, to + * the mean conjunction of Tishri of the Jewish year. BeHaRaD is 23:11:20 on Sunday night(5 hours 204/1080 + * chalakim after sunset on Sunday evening). */ public static int getJewishCalendarElapsedDays(int year) { long chalakimSince = getChalakimSinceMoladTohu(year, TISHREI); @@ -466,56 +466,35 @@ public static int getJewishCalendarElapsedDays(int year) { return addDechiyos(year, moladDay, moladParts); } - // private static int getJewishCalendarElapsedDaysOLD(int year) { - // // Jewish lunar month = 29 days, 12 hours and 793 chalakim - // // Molad Tohu = BeHaRaD - Monday, 5 hours (11 PM) and 204 chalakim - // final int chalakimTashTZag = 793; // chalakim in a lunar month - // final int chalakimTohuRaD = 204; // chalakim from original molad Tohu BeHaRaD - // final int hoursTohuHa = 5; // hours from original molad Tohu BeHaRaD - // final int dayTohu = 1; // Monday (0 based) - // - // int monthsElapsed = (235 * ((year - 1) / 19)) // Months in complete 19 year lunar (Metonic) cycles so far - // + (12 * ((year - 1) % 19)) // Regular months in this cycle - // + ((7 * ((year - 1) % 19) + 1) / 19); // Leap months this cycle - // // start with Molad Tohu BeHaRaD - // // start with RaD of BeHaRaD and add TaShTzaG (793) chalakim plus elapsed chalakim - // int partsElapsed = chalakimTohuRaD + chalakimTashTZag * (monthsElapsed % 1080); - // // start with Ha hours of BeHaRaD, add 12 hour remainder of lunar month add hours elapsed - // int hoursElapsed = hoursTohuHa + 12 * monthsElapsed + 793 * (monthsElapsed / 1080) + partsElapsed / 1080; - // // start with Monday of BeHaRaD = 1 (0 based), add 29 days of the lunar months elapsed - // int conjunctionDay = dayTohu + 29 * monthsElapsed + hoursElapsed / 24; - // int conjunctionParts = 1080 * (hoursElapsed % 24) + partsElapsed % 1080; - // return addDechiyos(year, conjunctionDay, conjunctionParts); - // } - - /** - * Adds the 4 dechiyos for molad Tishrei. These are: + /** + * Adds the 4 dechiyos for molad Tishrei. These are: *

    - *
  1. Lo ADU Rosh - Rosh Hashana can't fall on a Sunday, Wednesday or Friday. If the molad fell on one of these - * days, Rosh Hashana is delayed to the following day.
  2. - *
  3. Molad Zaken - If the molad of Tishrei falls after 12 noon, Rosh Hashana is delayed to the following day. If - * the following day is ADU, it will be delayed an additional day.
  4. - *
  5. GaTRaD - If on a non leap year the molad of Tishrei falls on a Tuesday (Ga) on or after 9 hours (T) and 204 - * chalakim (TRaD) it is delayed till Thursday (one day delay, plus one day for Lo ADU Rosh)
  6. - *
  7. BeTuTaKFoT - if the year following a leap year falls on a Monday (Be) on or after 15 hours (Tu) and 589 - * chalakim (TaKFoT) it is delayed till Tuesday
  8. + *
  9. Lo ADU Rosh - Rosh Hashana can't fall on a Sunday, Wednesday or Friday. If the molad fell on one + * of these days, Rosh Hashana is delayed to the following day.
  10. + *
  11. Molad Zaken - If the molad of Tishrei falls after 12 noon, Rosh Hashana is delayed to the following + * day. If the following day is ADU, it will be delayed an additional day.
  12. + *
  13. GaTRaD - If on a non leap year the molad of Tishrei falls on a Tuesday (Ga) on or after 9 hours + * (T) and (RaD 204 chalakim it is delayed till Thursday (one day delay, plus one day for + * Lo ADU Rosh)
  14. + *
  15. BeTuTaKPaT - if the year following a leap year falls on a Monday (Be) on or after 15 hours + * (Tu) and 589 chalakim (TaKPaT) it is delayed till Tuesday
  16. *
* * @param year the year - * @param moladDay the molad day - * @param moladParts the molad parts + * @param moladDay the molad day + * @param moladParts the molad parts * @return the number of elapsed days in the JewishCalendar adjusted for the 4 dechiyos. */ private static int addDechiyos(int year, int moladDay, int moladParts) { int roshHashanaDay = moladDay; // if no dechiyos - // delay Rosh Hashana for the dechiyos of the Molad - new moon 1 - Molad Zaken, 2- GaTRaD 3- BeTuTaKFoT + // delay Rosh Hashana for the dechiyos of the Molad - new moon 1 - Molad Zaken, 2- GaTRaD 3- BeTuTaKPaT if ((moladParts >= 19440) // Dechiya of Molad Zaken - molad is >= midday (18 hours * 1080 chalakim) || (((moladDay % 7) == 2) // start Dechiya of GaTRaD - Ga = is a Tuesday && (moladParts >= 9924) // TRaD = 9 hours, 204 parts or later (9 * 1080 + 204) - && !isJewishLeapYear(year)) // of a non-leap year-end Dechiya of GaTRaD - || (((moladDay % 7) == 1) // start Dechiya of BeTuTaKFoT - Be = is on a Monday - && (moladParts >= 16789) // TRaD = 15 hours, 589 parts or later (15 * 1080 + 589) - && (isJewishLeapYear(year - 1)))) { // in a year following a leap year-end Dechiya of BeTuTaKFoT + && !isJewishLeapYear(year)) // of a non-leap year - end Dechiya of GaTRaD + || (((moladDay % 7) == 1) // start Dechiya of BeTuTaKPaT - Be = is on a Monday + && (moladParts >= 16789) // TUTaKPaT part of BeTuTaKPaT = 15 hours, 589 parts or later (15 * 1080 + 589) + && (isJewishLeapYear(year - 1)))) { // in a year following a leap year - end Dechiya of BeTuTaKPaT roshHashanaDay += 1; // Then postpone Rosh HaShanah one day } // start 4th Dechiya - Lo ADU Rosh - Rosh Hashana can't occur on A- sunday, D- Wednesday, U - Friday @@ -528,21 +507,21 @@ private static int addDechiyos(int year, int moladDay, int moladParts) { } /** - * Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu to the year - * and month passed in. + * Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu + * to the year and month passed in. * * @param year * the Jewish year * @param month - * the Jewish month the Jewish month, with the month numbers starting from Nisan. Use the JewishDate + * the Jewish month the Jewish month, with the month numbers starting from Nissan. Use the JewishDate * constants such as {@link JewishDate#TISHREI}. - * @return the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu + * @return the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu */ private static long getChalakimSinceMoladTohu(int year, int month) { // Jewish lunar month = 29 days, 12 hours and 793 chalakim // chalakim since Molad Tohu BeHaRaD - 1 day, 5 hours and 204 chalakim int monthOfYear = getJewishMonthOfYear(year, month); - int monthsElapsed = (235 * ((year - 1) / 19)) // Months in complete 19 year lunar (Metonic) cycles so far + int monthsElapsed = (235 * ((year - 1) / 19)) // Months in complete 19-year lunar (Metonic) cycles so far + (12 * ((year - 1) % 19)) // Regular months in this cycle + ((7 * ((year - 1) % 19) + 1) / 19) // Leap months this cycle + (monthOfYear - 1); // add elapsed months till the start of the molad of the month @@ -551,10 +530,10 @@ private static long getChalakimSinceMoladTohu(int year, int month) { } /** - * 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. + * 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. * - * @return the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu + * @return the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu */ public long getChalakimSinceMoladTohu() { return getChalakimSinceMoladTohu(jewishYear, jewishMonth); @@ -562,7 +541,7 @@ public long getChalakimSinceMoladTohu() { /** * Converts the {@link JewishDate#NISSAN} based constants used by this class to numeric month starting from - * {@link JewishDate#TISHREI}. This is required for Molad calculations. + * {@link JewishDate#TISHREI}. This is required for molad calculations. * * @param year * The Jewish year @@ -576,11 +555,12 @@ private static int getJewishMonthOfYear(int year, int month) { } /** - * Validates the components of a Jewish date for validity. It will throw an {@link IllegalArgumentException} if the - * Jewish date is earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a - * {@link #isJewishLeapYear(int) leap year}), the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 - * or > 59 or chalakim < 0 or > 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the chalakim into - * minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793/TaShTzaG). + * Validates the components of a Jewish date for validity. It will throw an {@link IllegalArgumentException} if the Jewish + * date is earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a {@link #isJewishLeapYear(int) + * leap year}), the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 or > 59 or + * chalakim < 0 or > 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the + * chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the + * case of 793 / TaShTzaG). * * @param year * the Jewish year to validate. It will reject any year <= 3761 (lower than the year 1 Gregorian). @@ -590,19 +570,20 @@ private static int getJewishMonthOfYear(int year, int month) { * the day of the Jewish month to validate. It will reject any value < 1 or > 30 TODO: check calling * methods to see if there is any reason that the class can validate that 30 is invalid for some months. * @param hours - * the hours (for molad calculations). It will reject an hour < 0 or > 23 + * the hours (for molad calculations). It will reject an hour < 0 or > 23 * @param minutes - * the minutes (for molad calculations). It will reject a minute < 0 or > 59 + * the minutes (for molad calculations). It will reject a minute < 0 or > 59 * @param chalakim - * the chalakim/parts (for molad calculations). It will reject a chalakim < 0 or > 17. For larger numbers - * such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim per minutes, so it would be 44 - * minutes and 1 chelek in the case of 793/TaShTzaG) + * the chalakim / parts (for molad calculations). It will reject a chalakim < 0 or > + * 17. For larger numbers such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim + * per minutes, so it would be 44 minutes and 1 chelek in the case of 793 / TaShTzaG) * * @throws IllegalArgumentException - * if a Jewish date earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a - * leap year), the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 or > 59 or - * chalakim < 0 or > 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the chalakim - * into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 (TaShTzaG). + * if a Jewish date earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a leap year), + * the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 or > 59 or chalakim + * < 0 or > 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the + *
chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek + * in the case of 793 (TaShTzaG). */ private static void validateJewishDate(int year, int month, int dayOfMonth, int hours, int minutes, int chalakim) { if (month < NISSAN || month > getLastMonthOfJewishYear(year)) { @@ -633,7 +614,7 @@ private static void validateJewishDate(int year, int month, int dayOfMonth, int throw new IllegalArgumentException( "Chalakim/parts < 0 or > 17 can't be set. " + chalakim - + " is invalid. For larger numbers such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 (TaShTzaG)"); + + " is invalid. For larger numbers such as 793 (TaShTzaG) break the chalakim into minutes (18 chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 (TaShTzaG)"); } } @@ -834,11 +815,11 @@ private void absDateToJewishDate() { while (gregorianAbsDate >= jewishDateToAbsDate(jewishYear + 1, TISHREI, 1)) { jewishYear++; } - // Search forward for month from either Tishri or Nisan. + // Search forward for month from either Tishri or Nissan. if (gregorianAbsDate < jewishDateToAbsDate(jewishYear, NISSAN, 1)) { jewishMonth = TISHREI;// Start at Tishri } else { - jewishMonth = NISSAN;// Start at Nisan + jewishMonth = NISSAN;// Start at Nissan } while (gregorianAbsDate > jewishDateToAbsDate(jewishYear, jewishMonth, getDaysInJewishMonth())) { jewishMonth++; @@ -853,7 +834,7 @@ private void absDateToJewishDate() { * @param year * the Jewish year. The year can't be negative * @param month - * the Jewish month starting with Nisan. Nisan expects a value of 1 etc. till Adar with a value of 12. For + * the Jewish month starting with Nissan. Nissan 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. Use the constants {@link JewishDate#NISSAN} * etc. * @param dayOfMonth @@ -868,14 +849,14 @@ private static int jewishDateToAbsDate(int year, int month, int dayOfMonth) { } /** - * Returns the molad for a given year and month. Returns a JewishDate {@link Object} set to the date of the molad + * Returns the molad for a given year and month. Returns a JewishDate {@link Object} set to the date of the molad * with the {@link #getMoladHours() hours}, {@link #getMoladMinutes() minutes} and {@link #getMoladChalakim() - * 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, + * 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. * - * @return a JewishDate {@link Object} set to the date of the molad with the {@link #getMoladHours() hours}, - * {@link #getMoladMinutes() minutes} and {@link #getMoladChalakim() chalakim} set. + * @return a JewishDate {@link Object} set to the date of the molad with the {@link #getMoladHours() hours}, + * {@link #getMoladMinutes() minutes} and {@link #getMoladChalakim() chalakim} set. */ public JewishDate getMolad() { JewishDate moladDate = new JewishDate(getChalakimSinceMoladTohu()); @@ -887,10 +868,10 @@ public JewishDate getMolad() { } /** - * Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in. + * Returns the number of days from the Jewish epoch from the number of chalakim from the epoch passed in. * * @param chalakim - * the number of chalakim since the beginning of Sunday prior to BaHaRaD + * the number of chalakim since the beginning of Sunday prior to BaHaRaD * @return the number of days from the Jewish epoch */ private static int moladToAbsDate(long chalakim) { @@ -898,26 +879,25 @@ private static int moladToAbsDate(long chalakim) { } /** - * 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 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). * - * @param molad the number of chalakim since the beginning of Sunday prior to BaHaRaD + * @param molad the number of chalakim since the beginning of Sunday prior to BaHaRaD */ public JewishDate(long molad) { absDateToDate(moladToAbsDate(molad)); - // long chalakimSince = getChalakimSinceMoladTohu(year, TISHREI);// tishrei int conjunctionDay = (int) (molad / (long) CHALAKIM_PER_DAY); int conjunctionParts = (int) (molad - conjunctionDay * (long) CHALAKIM_PER_DAY); setMoladTime(conjunctionParts); } /** - * Sets the molad time (hours minutes and chalakim) based on the number of chalakim since the start of the day. + * Sets the molad time (hours minutes and chalakim) based on the number of chalakim since the start of the day. * * @param chalakim - * the number of chalakim since the start of the day. + * the number of chalakim since the start of the day. */ private void setMoladTime(int chalakim) { int adjustedChalakim = chalakim; @@ -942,7 +922,7 @@ private static int getDaysSinceStartOfJewishYear(int year, int month, int dayOfM int elapsedDays = dayOfMonth; // Before Tishrei (from Nissan to Tishrei), add days in prior months if (month < TISHREI) { - // this year before and after Nisan. + // this year before and after Nissan. for (int m = TISHREI; m <= getLastMonthOfJewishYear(year); m++) { elapsedDays += getDaysInJewishMonth(m, year); } @@ -1130,7 +1110,7 @@ private void setInternalGregorianDate(int year, int month, int dayOfMonth) { * @param year * the Jewish year. The year can't be negative * @param month - * the Jewish month starting with Nisan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for + * the Jewish month starting with Nissan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for * Adar II. Use the constants {@link #NISSAN} ... {@link #ADAR} (or {@link #ADAR_II} for a leap year Adar * II) to avoid any confusion. * @param dayOfMonth @@ -1150,7 +1130,7 @@ public void setJewishDate(int year, int month, int dayOfMonth) { * @param year * the Jewish year. The year can't be negative * @param month - * the Jewish month starting with Nisan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for + * the Jewish month starting with Nissan. A value of 1 is expected for Nissan ... 12 for Adar and 13 for * Adar II. Use the constants {@link #NISSAN} ... {@link #ADAR} (or {@link #ADAR_II} for a leap year Adar * II) to avoid any confusion. * @param dayOfMonth @@ -1158,18 +1138,18 @@ public void setJewishDate(int year, int month, int dayOfMonth) { * has 29 days, the day will be set as 29. * * @param hours - * the hour of the day. Used for Molad calculations + * the hour of the day. Used for molad calculations * @param minutes - * the minutes. Used for Molad calculations + * the minutes. Used for molad calculations * @param chalakim - * the chalakim/parts. Used for Molad calculations. The chalakim should not exceed 17. Minutes should be - * used for larger numbers. + * the chalakim / parts. Used for molad calculations. The chalakim should not + * exceed 17. Minutes should be used for larger numbers. * * @throws IllegalArgumentException - * if a Jewish date earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a - * leap year), the day of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 > 59 or chalakim < 0 > - * 17. For larger a larger number of chalakim such as 793 (TaShTzaG) break the chalakim into minutes (18 - * chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 (TaShTzaG). + * if a Jewish date earlier than 18 Teves, 3761 (1/1/1 Gregorian), a month < 1 or > 12 (or 13 on a leap year), the day + * of month is < 1 or > 30, an hour < 0 or > 23, a minute < 0 > 59 or chalakim < 0 > 17. For + * larger a larger number of chalakim such as 793 (TaShTzaG) break the chalakim into minutes (18 + * chalakim per minutes, so it would be 44 minutes and 1 chelek in the case of 793 (TaShTzaG). */ public void setJewishDate(int year, int month, int dayOfMonth, int hours, int minutes, int chalakim) { validateJewishDate(year, month, dayOfMonth, hours, minutes, chalakim); @@ -1313,7 +1293,7 @@ public void forward(int field, int amount) { /** * Forward the Jewish date by the number of months passed in. - * FIXME: Deal with forwarding a date such as 30 Nisan by a month. 30 Iyar does not exist. This should be dealt with similar to + * FIXME: Deal with forwarding a date such as 30 Nissan by a month. 30 Iyar does not exist. This should be dealt with similar to * the way that the Java Calendar behaves (not that simple since there is a difference between add() or roll(). * * @throws IllegalArgumentException if the amount is less than 1 @@ -1443,10 +1423,10 @@ public int getGregorianYear() { } /** - * Returns the Jewish month 1-12 (or 13 years in a leap year). The month count starts with 1 for Nisan and goes to + * Returns the Jewish month 1-12 (or 13 years in a leap year). The month count starts with 1 for Nissan and goes to * 13 for Adar II * - * @return the Jewish month from 1 to 12 (or 13 years in a leap year). The month count starts with 1 for Nisan and + * @return the Jewish month from 1 to 12 (or 13 years in a leap year). The month count starts with 1 for Nissan and * goes to 13 for Adar II */ public int getJewishMonth() { @@ -1524,7 +1504,7 @@ public void setGregorianDayOfMonth(int dayOfMonth) { * sets the Jewish month. * * @param month - * the Jewish month from 1 to 12 (or 13 years in a leap year). The month count starts with 1 for Nisan + * the Jewish month from 1 to 12 (or 13 years in a leap year). The month count starts with 1 for Nissan * and goes to 13 for Adar II * @throws IllegalArgumentException * if a month < 1 or > 12 (or 13 on a leap year) is passed in @@ -1570,10 +1550,10 @@ public Object clone() { } catch (CloneNotSupportedException cnse) { // Required by the compiler. Should never be reached since we implement clone() } - if (clone != null) { - clone.setInternalGregorianDate(gregorianYear, gregorianMonth, gregorianDayOfMonth); - } - return clone; + if (clone != null) { + clone.setInternalGregorianDate(gregorianYear, gregorianMonth, gregorianDayOfMonth); + } + return clone; } /**