From b30838982dcf33e304604293dee1acbdb2d8e204 Mon Sep 17 00:00:00 2001 From: Ely Jacobi <47622014+Elyahu41@users.noreply.github.com> Date: Sun, 14 Jan 2024 10:29:26 -0700 Subject: [PATCH] these are the simple code improvements (#231) Thanks @Elyahu41 --- .mvn/wrapper/MavenWrapperDownloader.java | 8 +-- .../zmanim/AstronomicalCalendar.java | 14 ++-- .../zmanim/ComplexZmanimCalendar.java | 4 +- .../com/kosherjava/zmanim/ZmanimCalendar.java | 45 ++++++------ .../hebrewcalendar/HebrewDateFormatter.java | 23 +++---- .../zmanim/hebrewcalendar/JewishCalendar.java | 68 ++++++++----------- .../zmanim/hebrewcalendar/JewishDate.java | 10 +-- .../zmanim/hebrewcalendar/TefilaRules.java | 39 +++++------ .../YerushalmiYomiCalculator.java | 18 ++--- .../zmanim/hebrewcalendar/YomiCalculator.java | 42 ++++++------ .../kosherjava/zmanim/util/GeoLocation.java | 57 ++++++++-------- .../zmanim/util/NOAACalculator.java | 10 ++- .../zmanim/util/SunTimesCalculator.java | 14 ++-- .../java/com/kosherjava/zmanim/util/Time.java | 8 +-- 14 files changed, 165 insertions(+), 195 deletions(-) diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index b901097f..d6cbe47d 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -54,7 +54,7 @@ public static void main(String args[]) { // wrapperUrl parameter. File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { + if (mavenWrapperPropertyFile.exists()) { FileInputStream mavenWrapperPropertyFileInputStream = null; try { mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); @@ -65,7 +65,7 @@ public static void main(String args[]) { System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); } finally { try { - if(mavenWrapperPropertyFileInputStream != null) { + if (mavenWrapperPropertyFileInputStream != null) { mavenWrapperPropertyFileInputStream.close(); } } catch (IOException e) { @@ -76,8 +76,8 @@ public static void main(String args[]) { System.out.println("- Downloading from: " + url); File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { System.out.println( "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); } diff --git a/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java b/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java index 8714fcfc..914770a9 100644 --- a/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java @@ -621,7 +621,7 @@ public double getSunriseSolarDipFromOffset(double minutes) { while (offsetByDegrees == null || ((minutes < 0.0 && offsetByDegrees.getTime() < offsetByTime.getTime()) || (minutes > 0.0 && offsetByDegrees.getTime() > offsetByTime.getTime()))) { - if(minutes > 0.0) { + if (minutes > 0.0) { degrees = degrees.add(incrementor); } else { degrees = degrees.subtract(incrementor); @@ -649,7 +649,7 @@ public double getSunsetSolarDipFromOffset(double minutes) { BigDecimal incrementor = new BigDecimal("0.001"); while (offsetByDegrees == null || ((minutes > 0.0 && offsetByDegrees.getTime() < offsetByTime.getTime()) || (minutes < 0.0 && offsetByDegrees.getTime() > offsetByTime.getTime()))) { - if(minutes > 0.0) { + if (minutes > 0.0) { degrees = degrees.add(incrementor); } else { degrees = degrees.subtract(incrementor); @@ -677,7 +677,7 @@ public double getSunsetSolarDipFromOffset(double minutes) { * @see GeoLocation#getLocalMeanTimeOffset() */ public Date getLocalMeanTime(double hours) { - if(hours < 0 || hours >= 24) { + if (hours < 0 || hours >= 24) { throw new IllegalArgumentException("Hours must between 0 and 23.9999..."); } return getTimeOffset(getDateFromTime(hours - getGeoLocation().getTimeZone().getRawOffset() @@ -832,9 +832,11 @@ public Object clone() { } catch (CloneNotSupportedException cnse) { // Required by the compiler. Should never be reached since we implement clone() } - clone.setGeoLocation((GeoLocation) getGeoLocation().clone()); - clone.setCalendar((Calendar) getCalendar().clone()); - clone.setAstronomicalCalculator((AstronomicalCalculator) getAstronomicalCalculator().clone()); + if (clone != null) { + clone.setGeoLocation((GeoLocation) getGeoLocation().clone()); + clone.setCalendar((Calendar) getCalendar().clone()); + clone.setAstronomicalCalculator((AstronomicalCalculator) getAstronomicalCalculator().clone()); + } return clone; } } diff --git a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java index 070ccf1e..8e49a609 100644 --- a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java @@ -1821,7 +1821,7 @@ public Date getMinchaGedola30Minutes() { * {@link AstronomicalCalendar} documentation. */ public Date getMinchaGedola72Minutes() { - if(isUseAstronomicalChatzosForOtherZmanim()) { + if (isUseAstronomicalChatzosForOtherZmanim()) { return getHalfDayBasedZman(getChatzos(), getTzais72(), 0.5); } else { return getMinchaGedola(getAlos72(), getTzais72(), true); @@ -1846,7 +1846,7 @@ public Date getMinchaGedola72Minutes() { * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ public Date getMinchaGedola16Point1Degrees() { - if(isUseAstronomicalChatzosForOtherZmanim()) { + if (isUseAstronomicalChatzosForOtherZmanim()) { return getHalfDayBasedZman(getChatzos(), getTzais16Point1Degrees(), 0.5); } else { return getMinchaGedola(getAlos16Point1Degrees(), getTzais16Point1Degrees(), true); diff --git a/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java b/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java index a952c077..47a42513 100644 --- a/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java @@ -266,7 +266,7 @@ public void setUseAstronomicalChatzosForOtherZmanim(boolean useAstronomicalChatz * @see com.kosherjava.zmanim.AstronomicalCalendar#getSunrise() */ protected Date getElevationAdjustedSunrise() { - if(isUseElevation()) { + if (isUseElevation()) { return super.getSunrise(); } return getSeaLevelSunrise(); @@ -282,7 +282,7 @@ protected Date getElevationAdjustedSunrise() { * @see com.kosherjava.zmanim.AstronomicalCalendar#getSunset() */ protected Date getElevationAdjustedSunset() { - if(isUseElevation()) { + if (isUseElevation()) { return super.getSunset(); } return getSeaLevelSunset(); @@ -370,11 +370,11 @@ public Date getAlos72() { * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ public Date getChatzos() { - if(useAstronomicalChatzos) { + if (useAstronomicalChatzos) { return getSunTransit(); // can be null of the calculator does not support astronomical chatzos } else { Date halfDayChatzos = getChatzosAsHalfDay(); - if(halfDayChatzos == null) { + if (halfDayChatzos == null) { return getSunTransit(); // can be null if the calculator does not support astronomical chatzos } else { return halfDayChatzos; @@ -447,7 +447,7 @@ public Date getChatzosAsHalfDay() { * detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ public Date getSofZmanShma(Date startOfDay, Date endOfDay, boolean synchronous) { - if(isUseAstronomicalChatzosForOtherZmanim() && synchronous) { + if (isUseAstronomicalChatzosForOtherZmanim() && synchronous) { return getHalfDayBasedZman(startOfDay, getChatzos(), 3); } else { return getShaahZmanisBasedZman(startOfDay, endOfDay, 3); @@ -588,7 +588,7 @@ public Date getCandleLighting() { * returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ public Date getSofZmanTfila(Date startOfDay, Date endOfDay, boolean synchronous) { - if(isUseAstronomicalChatzosForOtherZmanim() && synchronous) { + if (isUseAstronomicalChatzosForOtherZmanim() && synchronous) { return getHalfDayBasedZman(startOfDay, getChatzos(), 4); } else { return getShaahZmanisBasedZman(startOfDay, endOfDay, 4); @@ -697,7 +697,7 @@ public Date getSofZmanTfilaMGA() { * @see #isUseAstronomicalChatzosForOtherZmanim() */ public Date getMinchaGedola(Date startOfDay, Date endOfDay, boolean synchronous) { - if(isUseAstronomicalChatzosForOtherZmanim() && synchronous) { + if (isUseAstronomicalChatzosForOtherZmanim() && synchronous) { return getHalfDayBasedZman(getChatzos(), endOfDay, 0.5); } else { return getShaahZmanisBasedZman(startOfDay, endOfDay, 6.5); @@ -784,7 +784,7 @@ public Date getMinchaGedola() { * @see ComplexZmanimCalendar#getSamuchLeMinchaKetana72Minutes() */ public Date getSamuchLeMinchaKetana(Date startOfDay, Date endOfDay, boolean synchronous) { - if(isUseAstronomicalChatzosForOtherZmanim() && synchronous) { + if (isUseAstronomicalChatzosForOtherZmanim() && synchronous) { return getHalfDayBasedZman(getChatzos(), endOfDay, 3); } else { return getShaahZmanisBasedZman(startOfDay, endOfDay, 9); @@ -845,7 +845,7 @@ public Date getSamuchLeMinchaKetana(Date startOfDay, Date endOfDay) { * be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ public Date getMinchaKetana(Date startOfDay, Date endOfDay, boolean synchronous) { - if(isUseAstronomicalChatzosForOtherZmanim() && synchronous) { + if (isUseAstronomicalChatzosForOtherZmanim() && synchronous) { return getHalfDayBasedZman(getChatzos(), endOfDay, 3.5); } else { return getShaahZmanisBasedZman(startOfDay, endOfDay, 9.5); @@ -927,7 +927,7 @@ public Date getMinchaKetana() { * will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ public Date getPlagHamincha(Date startOfDay, Date endOfDay, boolean synchronous) { - if(isUseAstronomicalChatzosForOtherZmanim() && synchronous) { + if (isUseAstronomicalChatzosForOtherZmanim() && synchronous) { return getHalfDayBasedZman(getChatzos(), endOfDay, 4.75); } else { return getShaahZmanisBasedZman(startOfDay, endOfDay, 10.75); @@ -1083,16 +1083,13 @@ public boolean isAssurBemlacha(Date currentTime, Date tzais, boolean inIsrael) { getCalendar().get(Calendar.DAY_OF_MONTH)); jewishCalendar.setInIsrael(inIsrael); - if(jewishCalendar.hasCandleLighting() && currentTime.compareTo(getElevationAdjustedSunset()) >= 0) { //erev shabbos, YT or YT sheni and after shkiah + if (jewishCalendar.hasCandleLighting() && currentTime.compareTo(getElevationAdjustedSunset()) >= 0) { //erev shabbos, YT or YT sheni and after shkiah return true; } - - if(jewishCalendar.isAssurBemelacha() && currentTime.compareTo(tzais) <= 0) { //is shabbos or YT and it is before tzais - return true; - } - - return false; - } + + //is shabbos or YT and it is before tzais + return jewishCalendar.isAssurBemelacha() && currentTime.compareTo(tzais) <= 0; + } /** * A generic utility method for calculating any shaah zmanis (temporal hour) based zman with the @@ -1143,18 +1140,18 @@ public Date getShaahZmanisBasedZman(Date startOfDay, Date endOfDay, double hours public double getPercentOfShaahZmanisFromDegrees(double degrees, boolean sunset) { Date seaLevelSunrise = getSeaLevelSunrise(); Date seaLevelSunset = getSeaLevelSunset(); - Date twilight = null; - if(sunset) { + Date twilight; + if (sunset) { twilight = getSunsetOffsetByDegrees(GEOMETRIC_ZENITH + degrees); } else { twilight = getSunriseOffsetByDegrees(GEOMETRIC_ZENITH + degrees); } - if(seaLevelSunrise == null || seaLevelSunset == null || twilight == null) { + if (seaLevelSunrise == null || seaLevelSunset == null || twilight == null) { return Double.MIN_VALUE; } double shaahZmanis = (seaLevelSunset.getTime() - seaLevelSunrise.getTime()) / 12.0; long riseSetToTwilight; - if(sunset) { + if (sunset) { riseSetToTwilight = twilight.getTime() - seaLevelSunset.getTime(); } else { riseSetToTwilight = seaLevelSunrise.getTime() - twilight.getTime(); @@ -1197,10 +1194,10 @@ public Date getHalfDayBasedZman(Date startOfHalfDay, Date endOfHalfDay, double h return null; } long shaahZmanis = getHalfDayBasedShaahZmanis(startOfHalfDay, endOfHalfDay); - if(shaahZmanis == Long.MIN_VALUE) { //defensive, should not be needed + if (shaahZmanis == Long.MIN_VALUE) { //defensive, should not be needed return null; } - if(hours >= 0) { // forward from start a day + if (hours >= 0) { // forward from start a day return getTimeOffset(startOfHalfDay, shaahZmanis * hours); } else { // subtract from end of day return getTimeOffset(endOfHalfDay, shaahZmanis * hours); diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java index 62f6df10..8e0d4e7f 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java @@ -116,13 +116,13 @@ public class HebrewDateFormatter { * שובה,שירה,הגדול, * חזון,נחמו" */ - private EnumMap hebrewParshaMap; + private final EnumMap hebrewParshaMap; /** * Default constructor sets the {@link EnumMap}s of Hebrew and default transliterated parshiyos. */ public HebrewDateFormatter() { - transliteratedParshaMap = new EnumMap(JewishCalendar.Parsha.class); + transliteratedParshaMap = new EnumMap<>(JewishCalendar.Parsha.class); transliteratedParshaMap.put(JewishCalendar.Parsha.NONE, ""); transliteratedParshaMap.put(JewishCalendar.Parsha.BERESHIS, "Bereshis"); transliteratedParshaMap.put(JewishCalendar.Parsha.NOACH, "Noach"); @@ -195,7 +195,7 @@ public HebrewDateFormatter() { transliteratedParshaMap.put(JewishCalendar.Parsha.CHAZON, "Chazon"); transliteratedParshaMap.put(JewishCalendar.Parsha.NACHAMU, "Nachamu"); - hebrewParshaMap = new EnumMap(JewishCalendar.Parsha.class); + hebrewParshaMap = new EnumMap<>(JewishCalendar.Parsha.class); hebrewParshaMap.put(JewishCalendar.Parsha.NONE, ""); hebrewParshaMap.put(JewishCalendar.Parsha.BERESHIS, "\u05D1\u05E8\u05D0\u05E9\u05D9\u05EA"); hebrewParshaMap.put(JewishCalendar.Parsha.NOACH, "\u05E0\u05D7"); @@ -292,7 +292,7 @@ public boolean isLongWeekFormat() { */ public void setLongWeekFormat(boolean longWeekFormat) { this.longWeekFormat = longWeekFormat; - if(longWeekFormat) { + if (longWeekFormat) { weekFormat = new SimpleDateFormat("EEEE"); } else { weekFormat = new SimpleDateFormat("EEE"); @@ -496,7 +496,6 @@ public String formatRoshChodesh(JewishCalendar jewishCalendar) { if (!jewishCalendar.isRoshChodesh()) { return ""; } - String formattedRoshChodesh = ""; int month = jewishCalendar.getJewishMonth(); if (jewishCalendar.getJewishDayOfMonth() == 30) { if (month < JewishCalendar.ADAR || (month == JewishCalendar.ADAR && jewishCalendar.isJewishLeapYear())) { @@ -509,7 +508,7 @@ public String formatRoshChodesh(JewishCalendar jewishCalendar) { // This method is only about formatting, so we shouldn't make any changes to the params passed in... jewishCalendar = (JewishCalendar) jewishCalendar.clone(); jewishCalendar.setJewishMonth(month); - formattedRoshChodesh = hebrewFormat ? hebrewHolidays[JewishCalendar.ROSH_CHODESH] + String formattedRoshChodesh = hebrewFormat ? hebrewHolidays[JewishCalendar.ROSH_CHODESH] : transliteratedHolidays[JewishCalendar.ROSH_CHODESH]; formattedRoshChodesh += " " + formatMonth(jewishCalendar); return formattedRoshChodesh; @@ -637,18 +636,18 @@ public void setTransliteratedMonthList(String[] transliteratedMonths) { */ public String formatDayOfWeek(JewishDate jewishDate) { if (hebrewFormat) { - if(isLongWeekFormat()) { + if (isLongWeekFormat()) { return hebrewDaysOfWeek[jewishDate.getDayOfWeek() - 1]; } else { - if(jewishDate.getDayOfWeek() == 7) { + if (jewishDate.getDayOfWeek() == 7) { return formatHebrewNumber(300); } else { return formatHebrewNumber(jewishDate.getDayOfWeek()); } } } else { - if(jewishDate.getDayOfWeek() == 7) { - if(isLongWeekFormat()) { + if (jewishDate.getDayOfWeek() == 7) { + if (isLongWeekFormat()) { return getTransliteratedShabbosDayOfWeek(); } else { return getTransliteratedShabbosDayOfWeek().substring(0,3); @@ -897,7 +896,7 @@ public String formatDafYomiBavli(Daf daf) { * @return the formatted daf. */ public String formatDafYomiYerushalmi(Daf daf) { - if(daf == null) { + if (daf == null) { if (hebrewFormat) { return Daf.getYerushalmiMasechtos()[39]; } else { @@ -990,7 +989,7 @@ public String formatHebrewNumber(int number) { int tens = number / 10; if (number % 10 == 0) { // if evenly divisible by 10 if (!singleDigitNumber) { - if(isUseFinalFormLetters()) { + if (isUseFinalFormLetters()) { sb.append(jTenEnds[tens]); // years like 5780 will end with a final form ף } else { sb.append(jTens[tens]); // years like 5780 will end with a regular פ diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java index 2bc86440..229e0b39 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java @@ -177,7 +177,7 @@ public class JewishCalendar extends JewishDate { * @see #getSpecialShabbos() * @see #getParshah() */ - public static enum Parsha { + public enum Parsha { /**NONE A week without any parsha such as Shabbos Chol Hamoed */NONE, /**BERESHIS*/BERESHIS, /**NOACH*/NOACH, /**LECH_LECHA*/LECH_LECHA, /**VAYERA*/VAYERA, /**CHAYEI_SARA*/CHAYEI_SARA, /**TOLDOS*/TOLDOS, /**VAYETZEI*/VAYETZEI, /**VAYISHLACH*/VAYISHLACH, /**VAYESHEV*/VAYESHEV, /**MIKETZ*/MIKETZ, /**VAYIGASH*/VAYIGASH, /**VAYECHI*/VAYECHI, @@ -387,11 +387,9 @@ public boolean isBirkasHachamah() { * Rosh Hashana as 1, we have to add 1 day for a total of 171. To this add a day since the tekufah is on a Tuesday * night, and we push off the bracha to Wednesday morning resulting in the 172 used in the calculation. */ - if (elapsedDays % (28 * 365.25) == 172) { // 28 years of 365.25 days + the offset from molad tohu mentioned above - return true; - } - return false; - } + // 28 years of 365.25 days + the offset from molad tohu mentioned above + return elapsedDays % (28 * 365.25) == 172; + } /** * Return the type of year for parsha calculations. The algorithm follows the @@ -564,28 +562,28 @@ public Parsha getSpecialShabbos() { } } if (getJewishMonth() == NISSAN) { - if(getJewishDayOfMonth() == 1) { + if (getJewishDayOfMonth() == 1) { return Parsha.HACHODESH; } - if(getJewishDayOfMonth() >= 8 && getJewishDayOfMonth() <= 14) { + if (getJewishDayOfMonth() >= 8 && getJewishDayOfMonth() <= 14) { return Parsha.HAGADOL; } } if (getJewishMonth() == AV) { - if(getJewishDayOfMonth() >= 4 && getJewishDayOfMonth() <= 9) { + if (getJewishDayOfMonth() >= 4 && getJewishDayOfMonth() <= 9) { return Parsha.CHAZON; } - if(getJewishDayOfMonth() >= 10 && getJewishDayOfMonth() <= 16) { + if (getJewishDayOfMonth() >= 10 && getJewishDayOfMonth() <= 16) { return Parsha.NACHAMU; } } if (getJewishMonth() == TISHREI) { - if(getJewishDayOfMonth() >= 3 && getJewishDayOfMonth() <= 8) { + if (getJewishDayOfMonth() >= 3 && getJewishDayOfMonth() <= 8) { return Parsha.SHUVA; } } - if(getParshah() == Parsha.BESHALACH) { + if (getParshah() == Parsha.BESHALACH) { return Parsha.SHIRA; } } @@ -617,11 +615,10 @@ public int getYomTovIndex() { || (!inIsrael && (day == 16 || day == 22))) { return PESACH; } - if (day >= 17 && day <= 20 - || (day == 16 && inIsrael)) { + if (day >= 17 && day <= 20 || day == 16) { return CHOL_HAMOED_PESACH; } - if ((day == 22 && inIsrael) || (day == 23 && !inIsrael)) { + if (day == 22 || day == 23 && !inIsrael) { return ISRU_CHAG; } if (isUseModernHolidays() @@ -661,7 +658,7 @@ public int getYomTovIndex() { if (day == 6 || (day == 7 && !inIsrael)) { return SHAVUOS; } - if ((day == 7 && inIsrael) || (day == 8 && !inIsrael)) { + if (day == 7 || day == 8 && !inIsrael) { return ISRU_CHAG; } break; @@ -707,7 +704,7 @@ public int getYomTovIndex() { if (day == 15 || (day == 16 && !inIsrael)) { return SUCCOS; } - if (day >= 17 && day <= 20 || (day == 16 && inIsrael)) { + if (day >= 17 && day <= 20 || day == 16) { return CHOL_HAMOED_SUCCOS; } if (day == 21) { @@ -719,7 +716,7 @@ public int getYomTovIndex() { if (day == 23 && !inIsrael) { return SIMCHAS_TORAH; } - if ((day == 23 && inIsrael) || (day == 24 && !inIsrael)) { + if (day == 23 || day == 24 && !inIsrael) { return ISRU_CHAG; } break; @@ -1061,19 +1058,16 @@ public boolean isYomKippurKatan() { int dayOfWeek = getDayOfWeek(); int month = getJewishMonth(); int day = getJewishDayOfMonth(); - if(month == JewishDate.ELUL || month == JewishDate.TISHREI || month == JewishDate.KISLEV || month == JewishDate.NISSAN) { + if (month == JewishDate.ELUL || month == JewishDate.TISHREI || month == JewishDate.KISLEV || month == JewishDate.NISSAN) { return false; } - if(day == 29 && dayOfWeek != Calendar.FRIDAY && dayOfWeek != Calendar.SATURDAY) { + if (day == 29 && dayOfWeek != Calendar.FRIDAY && dayOfWeek != Calendar.SATURDAY) { return true; } - - if((day == 27 || day == 28) && dayOfWeek == Calendar.THURSDAY ) { - return true; - } - return false; - } + + return (day == 27 || day == 28) && dayOfWeek == Calendar.THURSDAY; + } /** * The Monday, Thursday and Monday after the first Shabbos after {@link #isRoshChodesh() Rosh Chodesh} @@ -1090,10 +1084,8 @@ public boolean isBeHaB() { int day = getJewishDayOfMonth(); if (month == JewishDate.CHESHVAN || month == JewishDate.IYAR) { - if((dayOfWeek == Calendar.MONDAY && day > 4 && day < 18) - || (dayOfWeek == Calendar.THURSDAY && day > 7 && day < 14)) { - return true; - } + return (dayOfWeek == Calendar.MONDAY && day > 4 && day < 18) + || (dayOfWeek == Calendar.THURSDAY && day > 7 && day < 14); } return false; } @@ -1163,7 +1155,7 @@ public boolean isChanukah() { * @see #setIsMukafChoma(boolean) */ public boolean isPurim() { - if(isMukafChoma) { + if (isMukafChoma) { return getYomTovIndex() == SHUSHAN_PURIM; } else { return getYomTovIndex() == PURIM; @@ -1427,9 +1419,7 @@ public int getTekufasTishreiElapsedDays() { public boolean isVeseinTalUmatarStartDate() { if (inIsrael) { // The 7th Cheshvan can't occur on Shabbos, so always return true for 7 Cheshvan - if (getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 7) { - return true; - } + return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 7; } else { if (getDayOfWeek() == Calendar.SATURDAY) { //Not recited on Friday night return false; @@ -1440,8 +1430,7 @@ public boolean isVeseinTalUmatarStartDate() { return getTekufasTishreiElapsedDays() == 47; } } - return false; // keep the compiler happy - } + } /** * Returns true if tonight is the first night to start reciting Vesein Tal Umatar Livracha ( @@ -1464,9 +1453,7 @@ public boolean isVeseinTalUmatarStartDate() { public boolean isVeseinTalUmatarStartingTonight() { if (inIsrael) { // The 7th Cheshvan can't occur on Shabbos, so always return true for 6 Cheshvan - if (getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 6) { - return true; - } + return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 6; } else { if (getDayOfWeek() == Calendar.FRIDAY) { //Not recited on Friday night return false; @@ -1477,8 +1464,7 @@ public boolean isVeseinTalUmatarStartingTonight() { return getTekufasTishreiElapsedDays() == 46; } } - return false; - } + } /** * Returns if Vesein Tal Umatar Livracha (Sheailas Geshamim) is recited. This will return diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java index 3286500e..e38af3e8 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java @@ -1306,7 +1306,7 @@ public void forward(int field, int amount) { } } else if (field == Calendar.MONTH) { forwardJewishMonth(amount); - } else if (field == Calendar.YEAR) { + } else { setJewishYear(getJewishYear() + amount); } } @@ -1324,7 +1324,7 @@ private void forwardJewishMonth(int amount) { throw new IllegalArgumentException("the amount of months to forward has to be greater than zero."); } for (int i = 0; i < amount; i++) { - if(getJewishMonth() == ELUL) { + if (getJewishMonth() == ELUL) { setJewishMonth(TISHREI); setJewishYear(getJewishYear() + 1); } else if ((! isJewishLeapYear() && getJewishMonth() == ADAR) @@ -1570,8 +1570,10 @@ public Object clone() { } catch (CloneNotSupportedException cnse) { // Required by the compiler. Should never be reached since we implement clone() } - clone.setInternalGregorianDate(gregorianYear, gregorianMonth, gregorianDayOfMonth); - return clone; + if (clone != null) { + clone.setInternalGregorianDate(gregorianYear, gregorianMonth, gregorianDayOfMonth); + } + return clone; } /** diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java index b5d7eab2..75ff8445 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java @@ -207,8 +207,7 @@ public boolean isTachanunRecitedShacharis(JewishCalendar jewishCalendar) { * @see #isTachanunRecitedShacharis(JewishCalendar) */ public boolean isTachanunRecitedMincha(JewishCalendar jewishCalendar) { - JewishCalendar tomorrow = new JewishCalendar(); - tomorrow = (JewishCalendar) jewishCalendar.clone(); + JewishCalendar tomorrow = (JewishCalendar) jewishCalendar.clone(); tomorrow.forward(Calendar.DATE, 1); if (!tachanunRecitedMinchaAllYear @@ -244,21 +243,18 @@ public boolean isTachanunRecitedMincha(JewishCalendar jewishCalendar) { public boolean isVeseinTalUmatarStartDate(JewishCalendar jewishCalendar) { if (jewishCalendar.getInIsrael()) { // The 7th Cheshvan can't occur on Shabbos, so always return true for 7 Cheshvan - if (jewishCalendar.getJewishMonth() == JewishDate.CHESHVAN && jewishCalendar.getJewishDayOfMonth() == 7) { - return true; - } + return jewishCalendar.getJewishMonth() == JewishDate.CHESHVAN && jewishCalendar.getJewishDayOfMonth() == 7; } else { if (jewishCalendar.getDayOfWeek() == Calendar.SATURDAY) { //Not recited on Friday night return false; } - if(jewishCalendar.getDayOfWeek() == Calendar.SUNDAY) { // When starting on Sunday, it can be the start date or delayed from Shabbos + if (jewishCalendar.getDayOfWeek() == Calendar.SUNDAY) { // When starting on Sunday, it can be the start date or delayed from Shabbos return jewishCalendar.getTekufasTishreiElapsedDays() == 48 || jewishCalendar.getTekufasTishreiElapsedDays() == 47; } else { return jewishCalendar.getTekufasTishreiElapsedDays() == 47; } } - return false; // keep the compiler happy - } + } /** * Returns true if tonight is the first night to start reciting Vesein Tal Umatar Livracha ( @@ -280,21 +276,18 @@ public boolean isVeseinTalUmatarStartDate(JewishCalendar jewishCalendar) { public boolean isVeseinTalUmatarStartingTonight(JewishCalendar jewishCalendar) { if (jewishCalendar.getInIsrael()) { // The 7th Cheshvan can't occur on Shabbos, so always return true for 6 Cheshvan - if (jewishCalendar.getJewishMonth() == JewishDate.CHESHVAN && jewishCalendar.getJewishDayOfMonth() == 6) { - return true; - } + return jewishCalendar.getJewishMonth() == JewishDate.CHESHVAN && jewishCalendar.getJewishDayOfMonth() == 6; } else { if (jewishCalendar.getDayOfWeek() == Calendar.FRIDAY) { //Not recited on Friday night return false; } - if(jewishCalendar.getDayOfWeek() == Calendar.SATURDAY) { // When starting on motzai Shabbos, it can be the start date or delayed from Friday night + if (jewishCalendar.getDayOfWeek() == Calendar.SATURDAY) { // When starting on motzai Shabbos, it can be the start date or delayed from Friday night return jewishCalendar.getTekufasTishreiElapsedDays() == 47 || jewishCalendar.getTekufasTishreiElapsedDays() == 46; } else { return jewishCalendar.getTekufasTishreiElapsedDays() == 46; } } - return false; - } + } /** * Returns if Vesein Tal Umatar Livracha (Sheailas Geshamim) is recited. This will return @@ -330,7 +323,7 @@ public boolean isVeseinTalUmatarRecited(JewishCalendar jewishCalendar) { * @see #isVeseinTalUmatarRecited(JewishCalendar) */ public boolean isVeseinBerachaRecited(JewishCalendar jewishCalendar) { - return ! isVeseinTalUmatarRecited(jewishCalendar); + return !isVeseinTalUmatarRecited(jewishCalendar); } /** @@ -402,20 +395,20 @@ public boolean isHallelRecited(JewishCalendar jewishCalendar) { int holidayIndex = jewishCalendar.getYomTovIndex(); boolean inIsrael = jewishCalendar.getInIsrael(); - if(jewishCalendar.isRoshChodesh()) { //RH returns false for RC + if (jewishCalendar.isRoshChodesh()) { //RH returns false for RC return true; } - if(jewishCalendar.isChanukah()) { + if (jewishCalendar.isChanukah()) { return true; } switch (month) { case JewishDate.NISSAN: - if(day >= 15 && ((inIsrael && day <= 21) || (!inIsrael && day <= 22))){ + if (day >= 15 && ((inIsrael && day <= 21) || (!inIsrael && day <= 22))){ return true; } break; case JewishDate.IYAR: // modern holidays - if(jewishCalendar.isUseModernHolidays() && (holidayIndex == JewishCalendar.YOM_HAATZMAUT + if (jewishCalendar.isUseModernHolidays() && (holidayIndex == JewishCalendar.YOM_HAATZMAUT || holidayIndex == JewishCalendar.YOM_YERUSHALAYIM)){ return true; } @@ -445,8 +438,8 @@ public boolean isHallelShalemRecited(JewishCalendar jewishCalendar) { int day = jewishCalendar.getJewishDayOfMonth(); int month = jewishCalendar.getJewishMonth(); boolean inIsrael = jewishCalendar.getInIsrael(); - if(isHallelRecited(jewishCalendar)) { - if((jewishCalendar.isRoshChodesh() && ! jewishCalendar.isChanukah()) + if (isHallelRecited(jewishCalendar)) { + if ((jewishCalendar.isRoshChodesh() && ! jewishCalendar.isChanukah()) || (month == JewishDate.NISSAN && ((inIsrael && day > 15) || (!inIsrael && day > 16)))) { return false; } else { @@ -498,12 +491,12 @@ public boolean isYaalehVeyavoRecited(JewishCalendar jewishCalendar) { * */ public boolean isMizmorLesodaRecited(JewishCalendar jewishCalendar) { - if(jewishCalendar.isAssurBemelacha()) { + if (jewishCalendar.isAssurBemelacha()) { return false; } int holidayIndex = jewishCalendar.getYomTovIndex(); - if(! isMizmorLesodaRecitedErevYomKippurAndPesach() + if (! isMizmorLesodaRecitedErevYomKippurAndPesach() && (holidayIndex == JewishCalendar.EREV_YOM_KIPPUR || holidayIndex == JewishCalendar.EREV_PESACH || jewishCalendar.isCholHamoedPesach())) { diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java index a1aaf21b..19e4031f 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java @@ -95,15 +95,15 @@ public static Daf getDafYomiYerushalmi(JewishCalendar calendar) { int total = dafNo - specialDays; // Finally find the daf. - for (int j = 0; j < BLATT_PER_MASECHTA.length; j++) { - - if (total < BLATT_PER_MASECHTA[j]) { - dafYomi = new Daf(masechta, total + 1); - break; - } - total -= BLATT_PER_MASECHTA[j]; - masechta++; - } + for (int i : BLATT_PER_MASECHTA) { + + if (total < i) { + dafYomi = new Daf(masechta, total + 1); + break; + } + total -= i; + masechta++; + } return dafYomi; } diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculator.java index cedfabef..108a0a3c 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculator.java @@ -80,8 +80,8 @@ public static Daf getDafYomiBavli(JewishCalendar jewishCalendar) { Daf dafYomi = null; int julianDay = getJulianDay(calendar); - int cycleNo = 0; - int dafNo = 0; + int cycleNo; + int dafNo; if (calendar.before(dafYomiStartDay)) { // TODO: should we return a null or throw an IllegalArgumentException? throw new IllegalArgumentException(calendar + " is prior to organized Daf Yomi Bavli cycles that started on " @@ -97,32 +97,30 @@ public static Daf getDafYomiBavli(JewishCalendar jewishCalendar) { int total = 0; int masechta = -1; - int blatt = 0; + int blatt; // Fix Shekalim for old cycles. if (cycleNo <= 7) { blattPerMasechta[4] = 13; - } else { - blattPerMasechta[4] = 22; // correct any change that may have been changed from a prior calculation } // Finally find the daf. - for (int j = 0; j < blattPerMasechta.length; j++) { - masechta++; - total = total + blattPerMasechta[j] - 1; - if (dafNo < total) { - blatt = 1 + blattPerMasechta[j] - (total - dafNo); - // Fiddle with the weird ones near the end. - if (masechta == 36) { - blatt += 21; - } else if (masechta == 37) { - blatt += 24; - } else if (masechta == 38) { - blatt += 32; - } - dafYomi = new Daf(masechta, blatt); - break; - } - } + for (int i : blattPerMasechta) { + masechta++; + total = total + i - 1; + if (dafNo < total) { + blatt = 1 + i - (total - dafNo); + // Fiddle with the weird ones near the end. + if (masechta == 36) { + blatt += 21; + } else if (masechta == 37) { + blatt += 24; + } else if (masechta == 38) { + blatt += 32; + } + dafYomi = new Daf(masechta, blatt); + break; + } + } return dafYomi; } diff --git a/src/main/java/com/kosherjava/zmanim/util/GeoLocation.java b/src/main/java/com/kosherjava/zmanim/util/GeoLocation.java index 37e39e49..1bd60477 100644 --- a/src/main/java/com/kosherjava/zmanim/util/GeoLocation.java +++ b/src/main/java/com/kosherjava/zmanim/util/GeoLocation.java @@ -15,6 +15,7 @@ */ package com.kosherjava.zmanim.util; +import java.util.Objects; import java.util.TimeZone; /** @@ -549,20 +550,18 @@ public double getRhumbLineDistance(GeoLocation location) { * @return The XML formatted String. */ public String toXML() { - StringBuilder sb = new StringBuilder(); - sb.append("\n"); - sb.append("\t").append(getLocationName()).append("\n"); - sb.append("\t").append(getLatitude()).append("\n"); - sb.append("\t").append(getLongitude()).append("\n"); - sb.append("\t").append(getElevation()).append(" Meters").append("\n"); - sb.append("\t").append(getTimeZone().getID()).append("\n"); - sb.append("\t").append(getTimeZone().getDisplayName()).append("\n"); - sb.append("\t").append(getTimeZone().getRawOffset() / HOUR_MILLIS) - .append("\n"); - sb.append("\t").append(getTimeZone().getDSTSavings() / HOUR_MILLIS) - .append("\n"); - sb.append(""); - return sb.toString(); + return "\n" + + "\t" + getLocationName() + "\n" + + "\t" + getLatitude() + "\n" + + "\t" + getLongitude() + "\n" + + "\t" + getElevation() + " Meters" + "\n" + + "\t" + getTimeZone().getID() + "\n" + + "\t" + getTimeZone().getDisplayName() + "\n" + + "\t" + getTimeZone().getRawOffset() / HOUR_MILLIS + + "\n" + + "\t" + getTimeZone().getDSTSavings() / HOUR_MILLIS + + "\n" + + ""; } /** @@ -577,8 +576,8 @@ public boolean equals(Object object) { return Double.doubleToLongBits(this.latitude) == Double.doubleToLongBits(geo.latitude) && Double.doubleToLongBits(this.longitude) == Double.doubleToLongBits(geo.longitude) && this.elevation == geo.elevation - && (this.locationName == null ? geo.locationName == null : this.locationName.equals(geo.locationName)) - && (this.timeZone == null ? geo.timeZone == null : this.timeZone.equals(geo.timeZone)); + && (Objects.equals(this.locationName, geo.locationName)) + && (Objects.equals(this.timeZone, geo.timeZone)); } /** @@ -606,17 +605,15 @@ public int hashCode() { * @see java.lang.Object#toString() */ public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("\nLocation Name:\t\t\t").append(getLocationName()); - sb.append("\nLatitude:\t\t\t").append(getLatitude()).append("\u00B0"); - sb.append("\nLongitude:\t\t\t").append(getLongitude()).append("\u00B0"); - sb.append("\nElevation:\t\t\t").append(getElevation()).append(" Meters"); - sb.append("\nTimezone ID:\t\t\t").append(getTimeZone().getID()); - sb.append("\nTimezone Display Name:\t\t").append(getTimeZone().getDisplayName()) - .append(" (").append(getTimeZone().getDisplayName(false, TimeZone.SHORT)).append(")"); - sb.append("\nTimezone GMT Offset:\t\t").append(getTimeZone().getRawOffset() / HOUR_MILLIS); - sb.append("\nTimezone DST Offset:\t\t").append(getTimeZone().getDSTSavings() / HOUR_MILLIS); - return sb.toString(); + return "\nLocation Name:\t\t\t" + getLocationName() + + "\nLatitude:\t\t\t" + getLatitude() + "\u00B0" + + "\nLongitude:\t\t\t" + getLongitude() + "\u00B0" + + "\nElevation:\t\t\t" + getElevation() + " Meters" + + "\nTimezone ID:\t\t\t" + getTimeZone().getID() + + "\nTimezone Display Name:\t\t" + getTimeZone().getDisplayName() + + " (" + getTimeZone().getDisplayName(false, TimeZone.SHORT) + ")" + + "\nTimezone GMT Offset:\t\t" + getTimeZone().getRawOffset() / HOUR_MILLIS + + "\nTimezone DST Offset:\t\t" + getTimeZone().getDSTSavings() / HOUR_MILLIS; } /** @@ -637,8 +634,10 @@ public Object clone() { } catch (CloneNotSupportedException cnse) { //Required by the compiler. Should never be reached since we implement clone() } - clone.timeZone = (TimeZone) getTimeZone().clone(); - clone.locationName = getLocationName(); + if (clone != null) { + clone.timeZone = (TimeZone) getTimeZone().clone(); + clone.locationName = getLocationName(); + } return clone; } } diff --git a/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java b/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java index 9fcef686..799c3a6e 100644 --- a/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java +++ b/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java @@ -243,8 +243,7 @@ private static double getSunApparentLongitude(double julianCenturies) { double sunTrueLongitude = getSunTrueLongitude(julianCenturies); double omega = 125.04 - 1934.136 * julianCenturies; - double lambda = sunTrueLongitude - 0.00569 - 0.00478 * Math.sin(Math.toRadians(omega)); - return lambda; // in degrees + return sunTrueLongitude - 0.00569 - 0.00478 * Math.sin(Math.toRadians(omega)); // in degrees } /** @@ -291,8 +290,7 @@ private static double getSunDeclination(double julianCenturies) { double lambda = getSunApparentLongitude(julianCenturies); double sint = Math.sin(Math.toRadians(obliquityCorrection)) * Math.sin(Math.toRadians(lambda)); - double theta = Math.toDegrees(Math.asin(sint)); - return theta; // in degrees + return Math.toDegrees(Math.asin(sint)); // in degrees } /** @@ -385,7 +383,7 @@ public static double getSolarElevation(Calendar cal, double lat, double lon) { double julianDay = getJulianDay(cal); double julianCenturies = getJulianCenturiesFromJulianDay(julianDay); - Double eot = getEquationOfTime(julianCenturies); + double eot = getEquationOfTime(julianCenturies); double longitude = (cal.get(Calendar.HOUR_OF_DAY) + 12.0) + (cal.get(Calendar.MINUTE) + eot + cal.get(Calendar.SECOND) / 60.0) / 60.0; @@ -418,7 +416,7 @@ public static double getSolarAzimuth(Calendar cal, double lat, double lon) { double julianDay = getJulianDay(cal); double julianCenturies = getJulianCenturiesFromJulianDay(julianDay); - Double eot = getEquationOfTime(julianCenturies); + double eot = getEquationOfTime(julianCenturies); double longitude = (cal.get(Calendar.HOUR_OF_DAY) + 12.0) + (cal.get(Calendar.MINUTE) + eot + cal.get(Calendar.SECOND) / 60.0) / 60.0; diff --git a/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java b/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java index 42c864fe..cc6110bc 100644 --- a/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java @@ -42,22 +42,18 @@ public String getCalculatorName() { * @see com.kosherjava.zmanim.util.AstronomicalCalculator#getUTCSunrise(Calendar, GeoLocation, double, boolean) */ public double getUTCSunrise(Calendar calendar, GeoLocation geoLocation, double zenith, boolean adjustForElevation) { - double doubleTime = Double.NaN; double elevation = adjustForElevation ? geoLocation.getElevation() : 0; double adjustedZenith = adjustZenith(zenith, elevation); - doubleTime = getTimeUTC(calendar, geoLocation, adjustedZenith, true); - return doubleTime; + return getTimeUTC(calendar, geoLocation, adjustedZenith, true); } /** * @see com.kosherjava.zmanim.util.AstronomicalCalculator#getUTCSunset(Calendar, GeoLocation, double, boolean) */ public double getUTCSunset(Calendar calendar, GeoLocation geoLocation, double zenith, boolean adjustForElevation) { - double doubleTime = Double.NaN; double elevation = adjustForElevation ? geoLocation.getElevation() : 0; double adjustedZenith = adjustZenith(zenith, elevation); - doubleTime = getTimeUTC(calendar, geoLocation, adjustedZenith, false); - return doubleTime; + return getTimeUTC(calendar, geoLocation, adjustedZenith, false); } /** @@ -233,7 +229,7 @@ private static double getTimeUTC(Calendar calendar, GeoLocation geoLocation, dou double sunRightAscensionHours = getSunRightAscensionHours(sunTrueLong); double cosLocalHourAngle = getCosLocalHourAngle(sunTrueLong, geoLocation.getLatitude(), zenith); - double localHourAngle = 0; + double localHourAngle; if (isSunrise) { localHourAngle = 360.0 - acosDeg(cosLocalHourAngle); } else { // sunset @@ -274,10 +270,10 @@ public double getUTCNoon(Calendar calendar, GeoLocation geoLocation) { double sunrise = getUTCSunrise(calendar, geoLocation, 90, false); double sunset = getUTCSunset(calendar, geoLocation, 90, false); double noon = sunrise + ((sunset - sunrise) / 2); - if(noon < 0) { + if (noon < 0) { noon += 12; } - if(noon < sunrise) { + if (noon < sunrise) { noon -= 12; } return noon; diff --git a/src/main/java/com/kosherjava/zmanim/util/Time.java b/src/main/java/com/kosherjava/zmanim/util/Time.java index 12575619..c3323449 100644 --- a/src/main/java/com/kosherjava/zmanim/util/Time.java +++ b/src/main/java/com/kosherjava/zmanim/util/Time.java @@ -37,22 +37,22 @@ public class Time { /** * @see #getHours() */ - private int hours = 0; + private int hours; /** * @see #getMinutes() */ - private int minutes = 0; + private int minutes; /** * @see #getSeconds() */ - private int seconds = 0; + private int seconds; /** * @see #getMilliseconds() */ - private int milliseconds = 0; + private int milliseconds; /** * @see #isNegative()