From 4a15861ccb83c0f11be3eb2587e119d5392ae7d1 Mon Sep 17 00:00:00 2001 From: "M. Waisberg" Date: Sun, 19 Jun 2022 00:33:51 +0300 Subject: [PATCH 1/3] Java library --- build.gradle | 23 ++++++++++------------- settings.gradle | 6 +----- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index 444994fa..8879f2f0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,32 +1,29 @@ -/* - * This file was generated by the Gradle 'init' task. - */ - plugins { - id 'java' - id 'java-library' - id 'maven-publish' + id "java-library" + id "maven-publish" } repositories { mavenLocal() maven { - url = uri('https://repo.maven.apache.org/maven2') + url = uri("https://repo.maven.apache.org/maven2") } } dependencies { - testImplementation 'junit:junit:4.12' + testImplementation "junit:junit:4.12" } -group = 'com.kosherjava' -version = '2.1.0' -sourceCompatibility = '8' -targetCompatibility = '1.8' +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} publishing { publications { maven(MavenPublication) { + group = "com.kosherjava" + version = "2.1.0" from(components.java) } } diff --git a/settings.gradle b/settings.gradle index 45b112b5..da5e7018 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1 @@ -/* - * This file was generated by the Gradle 'init' task. - */ - -rootProject.name = 'zmanim' +rootProject.name = "zmanim" From 43b35963dcb863b201feb34efda12ebd98f90087 Mon Sep 17 00:00:00 2001 From: "M. Waisberg" Date: Mon, 20 Jun 2022 22:40:04 +0300 Subject: [PATCH 2/3] Java Date was deprecated ages ago --- .../zmanim/AstronomicalCalendar.java | 74 ++-- .../zmanim/ComplexZmanimCalendar.java | 411 +++++++++--------- .../com/kosherjava/zmanim/ZmanimCalendar.java | 71 ++- .../zmanim/hebrewcalendar/JewishCalendar.java | 36 +- 4 files changed, 296 insertions(+), 296 deletions(-) diff --git a/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java b/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java index 343e276e..47dd4552 100644 --- a/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java @@ -17,7 +17,6 @@ import java.math.BigDecimal; import java.util.Calendar; -import java.util.Date; import java.util.TimeZone; import com.kosherjava.zmanim.util.AstronomicalCalculator; @@ -92,6 +91,9 @@ public class AstronomicalCalendar implements Cloneable { /** constant for milliseconds in an hour (3,600,000) */ static final long HOUR_MILLIS = MINUTE_MILLIS * 60; + /** Invalid date. */ + public static final long NEVER = Long.MIN_VALUE; + /** * The Java Calendar encapsulated by this class to track the current date used by the class */ @@ -123,7 +125,7 @@ public class AstronomicalCalendar implements Cloneable { * @see #getSeaLevelSunrise() * @see AstronomicalCalendar#getUTCSunrise */ - public Date getSunrise() { + public Long getSunrise() { double sunrise = getUTCSunrise(GEOMETRIC_ZENITH); if (Double.isNaN(sunrise)) { return null; @@ -145,7 +147,7 @@ public Date getSunrise() { * @see AstronomicalCalendar#getUTCSeaLevelSunrise * @see #getSeaLevelSunset() */ - public Date getSeaLevelSunrise() { + public Long getSeaLevelSunrise() { double sunrise = getUTCSeaLevelSunrise(GEOMETRIC_ZENITH); if (Double.isNaN(sunrise)) { return null; @@ -162,7 +164,7 @@ public Date getSeaLevelSunrise() { * can't be computed, null will be returned. See detailed explanation on top of the page. * @see #CIVIL_ZENITH */ - public Date getBeginCivilTwilight() { + public Long getBeginCivilTwilight() { return getSunriseOffsetByDegrees(CIVIL_ZENITH); } @@ -175,7 +177,7 @@ public Date getBeginCivilTwilight() { * calculation can't be computed null will be returned. See detailed explanation on top of the page. * @see #NAUTICAL_ZENITH */ - public Date getBeginNauticalTwilight() { + public Long getBeginNauticalTwilight() { return getSunriseOffsetByDegrees(NAUTICAL_ZENITH); } @@ -188,7 +190,7 @@ public Date getBeginNauticalTwilight() { * calculation can't be computed, null will be returned. See detailed explanation on top of the page. * @see #ASTRONOMICAL_ZENITH */ - public Date getBeginAstronomicalTwilight() { + public Long getBeginAstronomicalTwilight() { return getSunriseOffsetByDegrees(ASTRONOMICAL_ZENITH); } @@ -211,7 +213,7 @@ public Date getBeginAstronomicalTwilight() { * @see #getSeaLevelSunset() * @see AstronomicalCalendar#getUTCSunset */ - public Date getSunset() { + public Long getSunset() { double sunset = getUTCSunset(GEOMETRIC_ZENITH); if (Double.isNaN(sunset)) { return null; @@ -232,7 +234,7 @@ public Date getSunset() { * @see AstronomicalCalendar#getSunset * @see AstronomicalCalendar#getUTCSeaLevelSunset 2see {@link #getSunset()} */ - public Date getSeaLevelSunset() { + public Long getSeaLevelSunset() { double sunset = getUTCSeaLevelSunset(GEOMETRIC_ZENITH); if (Double.isNaN(sunset)) { return null; @@ -249,7 +251,7 @@ public Date getSeaLevelSunset() { * the calculation can't be computed, null will be returned. See detailed explanation on top of the page. * @see #CIVIL_ZENITH */ - public Date getEndCivilTwilight() { + public Long getEndCivilTwilight() { return getSunsetOffsetByDegrees(CIVIL_ZENITH); } @@ -261,7 +263,7 @@ public Date getEndCivilTwilight() { * page. * @see #NAUTICAL_ZENITH */ - public Date getEndNauticalTwilight() { + public Long getEndNauticalTwilight() { return getSunsetOffsetByDegrees(NAUTICAL_ZENITH); } @@ -273,13 +275,13 @@ public Date getEndNauticalTwilight() { * of the page. * @see #ASTRONOMICAL_ZENITH */ - public Date getEndAstronomicalTwilight() { + public Long getEndAstronomicalTwilight() { return getSunsetOffsetByDegrees(ASTRONOMICAL_ZENITH); } /** * A utility method that returns a date offset by the offset time passed in as a parameter. This method casts the - * offset as a long and calls {@link #getTimeOffset(Date, long)}. + * offset as a long and calls {@link #getTimeOffset(Long, long)}. * * @param time * the start time @@ -287,7 +289,7 @@ public Date getEndAstronomicalTwilight() { * the offset in milliseconds to add to the time * @return the {@link java.util.Date}with the offset added to it */ - public static Date getTimeOffset(Date time, double offset) { + public static Long getTimeOffset(Long time, double offset) { return getTimeOffset(time, (long) offset); } @@ -303,11 +305,11 @@ public static Date getTimeOffset(Date time, double offset) { * the offset in milliseconds to add to the time. * @return the {@link java.util.Date} with the offset in milliseconds added to it */ - public static Date getTimeOffset(Date time, long offset) { - if (time == null || offset == Long.MIN_VALUE) { + public static Long getTimeOffset(Long time, long offset) { + if (time == null || offset == NEVER) { return null; } - return new Date(time.getTime() + offset); + return time + offset; } /** @@ -325,7 +327,7 @@ public static Date getTimeOffset(Date time, long offset) { * not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the * page. */ - public Date getSunriseOffsetByDegrees(double offsetZenith) { + public Long getSunriseOffsetByDegrees(double offsetZenith) { double dawn = getUTCSunrise(offsetZenith); if (Double.isNaN(dawn)) { return null; @@ -348,7 +350,7 @@ public Date getSunriseOffsetByDegrees(double offsetZenith) { * rise, and one where it does not set, a null will be returned. See detailed explanation on top of the * page. */ - public Date getSunsetOffsetByDegrees(double offsetZenith) { + public Long getSunsetOffsetByDegrees(double offsetZenith) { double sunset = getUTCSunset(offsetZenith); if (Double.isNaN(sunset)) { return null; @@ -454,12 +456,12 @@ public double getUTCSeaLevelSunset(double zenith) { * * @see #getSunrise() * @see #getSunset() - * @see #getTemporalHour(Date, Date) + * @see #getTemporalHour(Long, Long) * * @return the long millisecond length of a temporal hour. If the calculation can't be computed, * {@link Long#MIN_VALUE} will be returned. See detailed explanation on top of the page. * - * @see #getTemporalHour(Date, Date) + * @see #getTemporalHour(Long, Long) */ public long getTemporalHour() { return getTemporalHour(getSeaLevelSunrise(), getSeaLevelSunset()); @@ -481,11 +483,11 @@ public long getTemporalHour() { * * @see #getTemporalHour() */ - public long getTemporalHour(Date startOfday, Date endOfDay) { + public long getTemporalHour(Long startOfday, Long endOfDay) { if (startOfday == null || endOfDay == null) { - return Long.MIN_VALUE; + return NEVER; } - return (endOfDay.getTime() - startOfday.getTime()) / 12; + return (endOfDay - startOfday) / 12; } /** @@ -498,10 +500,10 @@ public long getTemporalHour(Date startOfday, Date endOfDay) { * @return the Date representing Sun's transit. If the calculation can't be computed such as in the * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does * not set, null will be returned. See detailed explanation on top of the page. - * @see #getSunTransit(Date, Date) + * @see #getSunTransit(Long, Long) * @see #getTemporalHour() */ - public Date getSunTransit() { + public Long getSunTransit() { return getSunTransit(getSeaLevelSunrise(), getSeaLevelSunset()); } @@ -523,7 +525,7 @@ public Date getSunTransit() { * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does * not set, null will be returned. See detailed explanation on top of the page. */ - public Date getSunTransit(Date startOfDay, Date endOfDay) { + public Long getSunTransit(Long startOfDay, Long endOfDay) { long temporalHour = getTemporalHour(startOfDay, endOfDay); return getTimeOffset(startOfDay, temporalHour * 6); } @@ -537,7 +539,7 @@ public Date getSunTransit(Date startOfDay, Date endOfDay) { * @param isSunrise true if the * @return The Date. */ - protected Date getDateFromTime(double time, boolean isSunrise) { + protected Long getDateFromTime(double time, boolean isSunrise) { if (Double.isNaN(time)) { return null; } @@ -570,7 +572,7 @@ protected Date getDateFromTime(double time, boolean isSunrise) { cal.set(Calendar.MINUTE, minutes); cal.set(Calendar.SECOND, seconds); cal.set(Calendar.MILLISECOND, (int) (calculatedTime * 1000)); - return cal.getTime(); + return cal.getTimeInMillis(); } /** @@ -585,14 +587,14 @@ protected Date getDateFromTime(double time, boolean isSunrise) { * @see #getSunsetSolarDipFromOffset(double) */ public double getSunriseSolarDipFromOffset(double minutes) { - Date offsetByDegrees = getSeaLevelSunrise(); - Date offsetByTime = getTimeOffset(getSeaLevelSunrise(), -(minutes * MINUTE_MILLIS)); + Long offsetByDegrees = getSeaLevelSunrise(); + Long offsetByTime = getTimeOffset(getSeaLevelSunrise(), -(minutes * MINUTE_MILLIS)); BigDecimal degrees = new BigDecimal(0); BigDecimal incrementor = new BigDecimal("0.0001"); - while (offsetByDegrees == null || ((minutes < 0.0 && offsetByDegrees.getTime() < offsetByTime.getTime()) || - (minutes > 0.0 && offsetByDegrees.getTime() > offsetByTime.getTime()))) { + while (offsetByDegrees == null || ((minutes < 0.0 && offsetByDegrees < offsetByTime) || + (minutes > 0.0 && offsetByDegrees > offsetByTime))) { if(minutes > 0.0) { degrees = degrees.add(incrementor); } else { @@ -615,12 +617,12 @@ public double getSunriseSolarDipFromOffset(double minutes) { * @see #getSunriseSolarDipFromOffset(double) */ public double getSunsetSolarDipFromOffset(double minutes) { - Date offsetByDegrees = getSeaLevelSunset(); - Date offsetByTime = getTimeOffset(getSeaLevelSunset(), minutes * MINUTE_MILLIS); + Long offsetByDegrees = getSeaLevelSunset(); + Long offsetByTime = getTimeOffset(getSeaLevelSunset(), minutes * MINUTE_MILLIS); BigDecimal degrees = new BigDecimal(0); BigDecimal incrementor = new BigDecimal("0.001"); - while (offsetByDegrees == null || ((minutes > 0.0 && offsetByDegrees.getTime() < offsetByTime.getTime()) || - (minutes < 0.0 && offsetByDegrees.getTime() > offsetByTime.getTime()))) { + while (offsetByDegrees == null || ((minutes > 0.0 && offsetByDegrees < offsetByTime) || + (minutes < 0.0 && offsetByDegrees > offsetByTime))) { if(minutes > 0.0) { degrees = degrees.add(incrementor); } else { diff --git a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java index 64e5f14c..d7745f9c 100644 --- a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java @@ -16,7 +16,6 @@ package com.kosherjava.zmanim; import java.util.Calendar; -import java.util.Date; import com.kosherjava.zmanim.util.AstronomicalCalculator; import com.kosherjava.zmanim.util.GeoLocation; import com.kosherjava.zmanim.hebrewcalendar.JewishCalendar; @@ -746,7 +745,7 @@ public long getShaahZmanis120MinutesZmanis() { * @see #getPlagHamincha120Minutes() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha120MinutesZmanis() { + public Long getPlagHamincha120MinutesZmanis() { return getPlagHamincha(getAlos120Zmanis(), getTzais120Zmanis()); } @@ -770,7 +769,7 @@ public Date getPlagHamincha120MinutesZmanis() { * @see #getPlagHamincha26Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha120Minutes() { + public Long getPlagHamincha120Minutes() { return getPlagHamincha(getAlos120(), getTzais120()); } @@ -804,7 +803,7 @@ public Date getPlagHamincha120Minutes() { * @see #getPlagHamincha60Minutes() * @see #getShaahZmanis60Minutes() */ - public Date getAlos60() { + public Long getAlos60() { return getTimeOffset(getSunrise(), -60 * MINUTE_MILLIS); } @@ -824,7 +823,7 @@ public Date getAlos60() { * documentation. * @see #getShaahZmanisGra() */ - public Date getAlos72Zmanis() { + public Long getAlos72Zmanis() { return getZmanisBasedOffset(-1.2); } @@ -841,7 +840,7 @@ public Date getAlos72Zmanis() { * a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getAlos96() { + public Long getAlos96() { return getTimeOffset(getElevationAdjustedSunrise(), -96 * MINUTE_MILLIS); } @@ -860,7 +859,7 @@ public Date getAlos96() { * documentation. * @see #getShaahZmanisGra() */ - public Date getAlos90Zmanis() { + public Long getAlos90Zmanis() { return getZmanisBasedOffset(-1.5); } @@ -879,7 +878,7 @@ public Date getAlos90Zmanis() { * documentation. * @see #getShaahZmanisGra() */ - public Date getAlos96Zmanis() { + public Long getAlos96Zmanis() { return getZmanisBasedOffset(-1.6); } @@ -896,7 +895,7 @@ public Date getAlos96Zmanis() { * a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getAlos90() { + public Long getAlos90() { return getTimeOffset(getElevationAdjustedSunrise(), -90 * MINUTE_MILLIS); } @@ -924,7 +923,7 @@ public Date getAlos90() { * @see #getAlos26Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getAlos120() { + public Long getAlos120() { return getTimeOffset(getElevationAdjustedSunrise(), -120 * MINUTE_MILLIS); } @@ -953,7 +952,7 @@ public Date getAlos120() { * @see #getAlos26Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getAlos120Zmanis() { + public Long getAlos120Zmanis() { return getZmanisBasedOffset(-2.0); } @@ -982,7 +981,7 @@ public Date getAlos120Zmanis() { * @see #getTzais26Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getAlos26Degrees() { + public Long getAlos26Degrees() { return getSunriseOffsetByDegrees(ZENITH_26_DEGREES); } @@ -996,7 +995,7 @@ public Date getAlos26Degrees() { * explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ASTRONOMICAL_ZENITH */ - public Date getAlos18Degrees() { + public Long getAlos18Degrees() { return getSunriseOffsetByDegrees(ASTRONOMICAL_ZENITH); } @@ -1015,7 +1014,7 @@ public Date getAlos18Degrees() { * explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ASTRONOMICAL_ZENITH */ - public Date getAlos19Degrees() { + public Long getAlos19Degrees() { return getSunriseOffsetByDegrees(ZENITH_19_DEGREES); } @@ -1034,7 +1033,7 @@ public Date getAlos19Degrees() { * @see #ZENITH_19_POINT_8 * @see #getAlos90() */ - public Date getAlos19Point8Degrees() { + public Long getAlos19Point8Degrees() { return getSunriseOffsetByDegrees(ZENITH_19_POINT_8); } @@ -1053,7 +1052,7 @@ public Date getAlos19Point8Degrees() { * @see #ZENITH_16_POINT_1 * @see #getAlos72() */ - public Date getAlos16Point1Degrees() { + public Long getAlos16Point1Degrees() { return getSunriseOffsetByDegrees(ZENITH_16_POINT_1); } @@ -1072,7 +1071,7 @@ public Date getAlos16Point1Degrees() { * explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_11_POINT_5 */ - public Date getMisheyakir11Point5Degrees() { + public Long getMisheyakir11Point5Degrees() { return getSunriseOffsetByDegrees(ZENITH_11_POINT_5); } @@ -1090,7 +1089,7 @@ public Date getMisheyakir11Point5Degrees() { * {@link AstronomicalCalendar} documentation. * @see #ZENITH_11_DEGREES */ - public Date getMisheyakir11Degrees() { + public Long getMisheyakir11Degrees() { return getSunriseOffsetByDegrees(ZENITH_11_DEGREES); } @@ -1108,7 +1107,7 @@ public Date getMisheyakir11Degrees() { * detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_10_POINT_2 */ - public Date getMisheyakir10Point2Degrees() { + public Long getMisheyakir10Point2Degrees() { return getSunriseOffsetByDegrees(ZENITH_10_POINT_2); } @@ -1141,7 +1140,7 @@ public Date getMisheyakir10Point2Degrees() { * @see #ZENITH_7_POINT_65 * @see #getMisheyakir9Point5Degrees() */ - public Date getMisheyakir7Point65Degrees() { + public Long getMisheyakir7Point65Degrees() { return getSunriseOffsetByDegrees(ZENITH_7_POINT_65); } @@ -1168,7 +1167,7 @@ public Date getMisheyakir7Point65Degrees() { * @see #ZENITH_9_POINT_5 * @see #getMisheyakir7Point65Degrees() */ - public Date getMisheyakir9Point5Degrees() { + public Long getMisheyakir9Point5Degrees() { return getSunriseOffsetByDegrees(ZENITH_9_POINT_5); } @@ -1188,7 +1187,7 @@ public Date getMisheyakir9Point5Degrees() { * @see #getShaahZmanis19Point8Degrees() * @see #getAlos19Point8Degrees() */ - public Date getSofZmanShmaMGA19Point8Degrees() { + public Long getSofZmanShmaMGA19Point8Degrees() { return getSofZmanShma(getAlos19Point8Degrees(), getTzais19Point8Degrees()); } @@ -1208,7 +1207,7 @@ public Date getSofZmanShmaMGA19Point8Degrees() { * @see #getShaahZmanis16Point1Degrees() * @see #getAlos16Point1Degrees() */ - public Date getSofZmanShmaMGA16Point1Degrees() { + public Long getSofZmanShmaMGA16Point1Degrees() { return getSofZmanShma(getAlos16Point1Degrees(), getTzais16Point1Degrees()); } @@ -1228,7 +1227,7 @@ public Date getSofZmanShmaMGA16Point1Degrees() { * @see #getShaahZmanis18Degrees() * @see #getAlos18Degrees() */ - public Date getSofZmanShmaMGA18Degrees() { + public Long getSofZmanShmaMGA18Degrees() { return getSofZmanShma(getAlos18Degrees(), getTzais18Degrees()); } @@ -1250,7 +1249,7 @@ public Date getSofZmanShmaMGA18Degrees() { * @see #getAlos72() * @see #getSofZmanShmaMGA() */ - public Date getSofZmanShmaMGA72Minutes() { + public Long getSofZmanShmaMGA72Minutes() { return getSofZmanShmaMGA(); } @@ -1272,7 +1271,7 @@ public Date getSofZmanShmaMGA72Minutes() { * @see #getShaahZmanis72MinutesZmanis() * @see #getAlos72Zmanis() */ - public Date getSofZmanShmaMGA72MinutesZmanis() { + public Long getSofZmanShmaMGA72MinutesZmanis() { return getSofZmanShma(getAlos72Zmanis(), getTzais72Zmanis()); } @@ -1292,7 +1291,7 @@ public Date getSofZmanShmaMGA72MinutesZmanis() { * @see #getShaahZmanis90Minutes() * @see #getAlos90() */ - public Date getSofZmanShmaMGA90Minutes() { + public Long getSofZmanShmaMGA90Minutes() { return getSofZmanShma(getAlos90(), getTzais90()); } @@ -1313,7 +1312,7 @@ public Date getSofZmanShmaMGA90Minutes() { * @see #getShaahZmanis90MinutesZmanis() * @see #getAlos90Zmanis() */ - public Date getSofZmanShmaMGA90MinutesZmanis() { + public Long getSofZmanShmaMGA90MinutesZmanis() { return getSofZmanShma(getAlos90Zmanis(), getTzais90Zmanis()); } @@ -1333,7 +1332,7 @@ public Date getSofZmanShmaMGA90MinutesZmanis() { * @see #getShaahZmanis96Minutes() * @see #getAlos96() */ - public Date getSofZmanShmaMGA96Minutes() { + public Long getSofZmanShmaMGA96Minutes() { return getSofZmanShma(getAlos96(), getTzais96()); } @@ -1354,7 +1353,7 @@ public Date getSofZmanShmaMGA96Minutes() { * @see #getShaahZmanis96MinutesZmanis() * @see #getAlos96Zmanis() */ - public Date getSofZmanShmaMGA96MinutesZmanis() { + public Long getSofZmanShmaMGA96MinutesZmanis() { return getSofZmanShma(getAlos96Zmanis(), getTzais96Zmanis()); } @@ -1384,7 +1383,7 @@ public Date getSofZmanShmaMGA96MinutesZmanis() { * @see #getSofZmanShmaFixedLocal() * @see #getSofZmanTfila2HoursBeforeChatzos() */ - public Date getSofZmanShma3HoursBeforeChatzos() { + public Long getSofZmanShma3HoursBeforeChatzos() { return getTimeOffset(getChatzos(), -180 * MINUTE_MILLIS); } @@ -1405,7 +1404,7 @@ public Date getSofZmanShma3HoursBeforeChatzos() { * @see #getShaahZmanis120Minutes() * @see #getAlos120() */ - public Date getSofZmanShmaMGA120Minutes() { + public Long getSofZmanShmaMGA120Minutes() { return getSofZmanShma(getAlos120(), getTzais120()); } @@ -1430,7 +1429,7 @@ public Date getSofZmanShmaMGA120Minutes() { * @see #getAlos16Point1Degrees() * @see #getSeaLevelSunset() */ - public Date getSofZmanShmaAlos16Point1ToSunset() { + public Long getSofZmanShmaAlos16Point1ToSunset() { return getSofZmanShma(getAlos16Point1Degrees(), getElevationAdjustedSunset()); } @@ -1452,7 +1451,7 @@ public Date getSofZmanShmaAlos16Point1ToSunset() { * @see #getAlos16Point1Degrees() * @see #getTzaisGeonim7Point083Degrees() */ - public Date getSofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees() { + public Long getSofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees() { return getSofZmanShma(getAlos16Point1Degrees(), getTzaisGeonim7Point083Degrees()); } @@ -1473,12 +1472,12 @@ public Date getSofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees() { * will be removed (likely in v3.0) pending confirmation from Rabbi Harfenes. */ @Deprecated // (since="1.3", forRemoval=true) // add back once Java 9 is the minimum supported version - public Date getSofZmanShmaKolEliyahu() { - Date chatzos = getFixedLocalChatzos(); + public Long getSofZmanShmaKolEliyahu() { + Long chatzos = getFixedLocalChatzos(); if (chatzos == null || getSunrise() == null) { return null; } - long diff = (chatzos.getTime() - getElevationAdjustedSunrise().getTime()) / 2; + long diff = (chatzos - getElevationAdjustedSunrise()) / 2; return getTimeOffset(chatzos, -diff); } @@ -1499,7 +1498,7 @@ public Date getSofZmanShmaKolEliyahu() { * @see #getShaahZmanis19Point8Degrees() * @see #getAlos19Point8Degrees() */ - public Date getSofZmanTfilaMGA19Point8Degrees() { + public Long getSofZmanTfilaMGA19Point8Degrees() { return getSofZmanTfila(getAlos19Point8Degrees(), getTzais19Point8Degrees()); } @@ -1520,7 +1519,7 @@ public Date getSofZmanTfilaMGA19Point8Degrees() { * @see #getShaahZmanis16Point1Degrees() * @see #getAlos16Point1Degrees() */ - public Date getSofZmanTfilaMGA16Point1Degrees() { + public Long getSofZmanTfilaMGA16Point1Degrees() { return getSofZmanTfila(getAlos16Point1Degrees(), getTzais16Point1Degrees()); } @@ -1541,7 +1540,7 @@ public Date getSofZmanTfilaMGA16Point1Degrees() { * @see #getShaahZmanis18Degrees() * @see #getAlos18Degrees() */ - public Date getSofZmanTfilaMGA18Degrees() { + public Long getSofZmanTfilaMGA18Degrees() { return getSofZmanTfila(getAlos18Degrees(), getTzais18Degrees()); } @@ -1563,7 +1562,7 @@ public Date getSofZmanTfilaMGA18Degrees() { * @see #getAlos72() * @see #getSofZmanShmaMGA() */ - public Date getSofZmanTfilaMGA72Minutes() { + public Long getSofZmanTfilaMGA72Minutes() { return getSofZmanTfilaMGA(); } @@ -1583,7 +1582,7 @@ public Date getSofZmanTfilaMGA72Minutes() { * @see #getShaahZmanis72MinutesZmanis() * @see #getAlos72Zmanis() */ - public Date getSofZmanTfilaMGA72MinutesZmanis() { + public Long getSofZmanTfilaMGA72MinutesZmanis() { return getSofZmanTfila(getAlos72Zmanis(), getTzais72Zmanis()); } @@ -1603,7 +1602,7 @@ public Date getSofZmanTfilaMGA72MinutesZmanis() { * @see #getShaahZmanis90Minutes() * @see #getAlos90() */ - public Date getSofZmanTfilaMGA90Minutes() { + public Long getSofZmanTfilaMGA90Minutes() { return getSofZmanTfila(getAlos90(), getTzais90()); } @@ -1624,7 +1623,7 @@ public Date getSofZmanTfilaMGA90Minutes() { * @see #getShaahZmanis90MinutesZmanis() * @see #getAlos90Zmanis() */ - public Date getSofZmanTfilaMGA90MinutesZmanis() { + public Long getSofZmanTfilaMGA90MinutesZmanis() { return getSofZmanTfila(getAlos90Zmanis(), getTzais90Zmanis()); } @@ -1644,7 +1643,7 @@ public Date getSofZmanTfilaMGA90MinutesZmanis() { * @see #getShaahZmanis96Minutes() * @see #getAlos96() */ - public Date getSofZmanTfilaMGA96Minutes() { + public Long getSofZmanTfilaMGA96Minutes() { return getSofZmanTfila(getAlos96(), getTzais96()); } @@ -1665,7 +1664,7 @@ public Date getSofZmanTfilaMGA96Minutes() { * @see #getShaahZmanis90MinutesZmanis() * @see #getAlos90Zmanis() */ - public Date getSofZmanTfilaMGA96MinutesZmanis() { + public Long getSofZmanTfilaMGA96MinutesZmanis() { return getSofZmanTfila(getAlos96Zmanis(), getTzais96Zmanis()); } @@ -1686,7 +1685,7 @@ public Date getSofZmanTfilaMGA96MinutesZmanis() { * @see #getShaahZmanis120Minutes() * @see #getAlos120() */ - public Date getSofZmanTfilaMGA120Minutes() { + public Long getSofZmanTfilaMGA120Minutes() { return getSofZmanTfila(getAlos120(), getTzais120()); } @@ -1703,7 +1702,7 @@ public Date getSofZmanTfilaMGA120Minutes() { * @see ZmanimCalendar#getChatzos() * @see #getSofZmanShma3HoursBeforeChatzos() */ - public Date getSofZmanTfila2HoursBeforeChatzos() { + public Long getSofZmanTfila2HoursBeforeChatzos() { return getTimeOffset(getChatzos(), -120 * MINUTE_MILLIS); } @@ -1724,7 +1723,7 @@ public Date getSofZmanTfila2HoursBeforeChatzos() { * @see #getMinchaGedola() * @see #getMinchaGedolaGreaterThan30() */ - public Date getMinchaGedola30Minutes() { + public Long getMinchaGedola30Minutes() { return getTimeOffset(getChatzos(), MINUTE_MILLIS * 30); } @@ -1744,7 +1743,7 @@ public Date getMinchaGedola30Minutes() { * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaGedola72Minutes() { + public Long getMinchaGedola72Minutes() { return getMinchaGedola(getAlos72(), getTzais72()); } @@ -1763,7 +1762,7 @@ public Date getMinchaGedola72Minutes() { * the sun may not reach low enough below the horizon for this calculation, a null will be returned. See * detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getMinchaGedola16Point1Degrees() { + public Long getMinchaGedola16Point1Degrees() { return getMinchaGedola(getAlos16Point1Degrees(), getTzais16Point1Degrees()); } @@ -1778,7 +1777,7 @@ public Date getMinchaGedola16Point1Degrees() { * where the sun does not rise, and one where it does not set, a null will be returned. See detailed * explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getMinchaGedolaGreaterThan30() { + public Long getMinchaGedolaGreaterThan30() { if (getMinchaGedola30Minutes() == null || getMinchaGedola() == null) { return null; } else { @@ -1803,7 +1802,7 @@ public Date getMinchaGedolaGreaterThan30() { * where the sun may not reach low enough below the horizon for this calculation, a null will be returned. * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getMinchaKetana16Point1Degrees() { + public Long getMinchaKetana16Point1Degrees() { return getMinchaKetana(getAlos16Point1Degrees(), getTzais16Point1Degrees()); } @@ -1823,7 +1822,7 @@ public Date getMinchaKetana16Point1Degrees() { * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaKetana72Minutes() { + public Long getMinchaKetana72Minutes() { return getMinchaKetana(getAlos72(), getTzais72()); } @@ -1841,7 +1840,7 @@ public Date getMinchaKetana72Minutes() { * @see #getAlos60() * @see #getTzais60() */ - public Date getPlagHamincha60Minutes() { + public Long getPlagHamincha60Minutes() { return getPlagHamincha(getAlos60(), getTzais60()); } @@ -1864,7 +1863,7 @@ public Date getPlagHamincha60Minutes() { * @see #getShaahZmanis72Minutes() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha72Minutes() { + public Long getPlagHamincha72Minutes() { return getPlagHamincha(getAlos72(), getTzais72()); } @@ -1887,7 +1886,7 @@ public Date getPlagHamincha72Minutes() { * @see #getShaahZmanis90Minutes() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha90Minutes() { + public Long getPlagHamincha90Minutes() { return getPlagHamincha(getAlos90(), getTzais90()); } @@ -1909,7 +1908,7 @@ public Date getPlagHamincha90Minutes() { * @see #getShaahZmanis96Minutes() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha96Minutes() { + public Long getPlagHamincha96Minutes() { return getPlagHamincha(getAlos96(), getTzais96()); } @@ -1929,7 +1928,7 @@ public Date getPlagHamincha96Minutes() { * {@link AstronomicalCalendar} documentation. */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha96MinutesZmanis() { + public Long getPlagHamincha96MinutesZmanis() { return getPlagHamincha(getAlos96Zmanis(), getTzais96Zmanis()); } @@ -1949,7 +1948,7 @@ public Date getPlagHamincha96MinutesZmanis() { * {@link AstronomicalCalendar} documentation. */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha90MinutesZmanis() { + public Long getPlagHamincha90MinutesZmanis() { return getPlagHamincha(getAlos90Zmanis(), getTzais90Zmanis()); } @@ -1969,7 +1968,7 @@ public Date getPlagHamincha90MinutesZmanis() { * {@link AstronomicalCalendar} documentation. */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha72MinutesZmanis() { + public Long getPlagHamincha72MinutesZmanis() { return getPlagHamincha(getAlos72Zmanis(), getTzais72Zmanis()); } @@ -1993,7 +1992,7 @@ public Date getPlagHamincha72MinutesZmanis() { * @see #getShaahZmanis16Point1Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha16Point1Degrees() { + public Long getPlagHamincha16Point1Degrees() { return getPlagHamincha(getAlos16Point1Degrees(), getTzais16Point1Degrees()); } @@ -2017,7 +2016,7 @@ public Date getPlagHamincha16Point1Degrees() { * @see #getShaahZmanis19Point8Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha19Point8Degrees() { + public Long getPlagHamincha19Point8Degrees() { return getPlagHamincha(getAlos19Point8Degrees(), getTzais19Point8Degrees()); } @@ -2042,7 +2041,7 @@ public Date getPlagHamincha19Point8Degrees() { * @see #getPlagHamincha120Minutes() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha26Degrees() { + public Long getPlagHamincha26Degrees() { return getPlagHamincha(getAlos26Degrees(), getTzais26Degrees()); } @@ -2066,7 +2065,7 @@ public Date getPlagHamincha26Degrees() { * @see #getShaahZmanis18Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagHamincha18Degrees() { + public Long getPlagHamincha18Degrees() { return getPlagHamincha(getAlos18Degrees(), getTzais18Degrees()); } @@ -2093,7 +2092,7 @@ public Date getPlagHamincha18Degrees() { * @see #getSeaLevelSunset() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getPlagAlosToSunset() { + public Long getPlagAlosToSunset() { return getPlagHamincha(getAlos16Point1Degrees(), getElevationAdjustedSunset()); } @@ -2115,7 +2114,7 @@ public Date getPlagAlosToSunset() { * @see #getAlos16Point1Degrees() * @see #getTzaisGeonim7Point083Degrees() */ - public Date getPlagAlos16Point1ToTzaisGeonim7Point083Degrees() { + public Long getPlagAlos16Point1ToTzaisGeonim7Point083Degrees() { return getPlagHamincha(getAlos16Point1Degrees(), getTzaisGeonim7Point083Degrees()); } @@ -2143,7 +2142,7 @@ public Date getPlagAlos16Point1ToTzaisGeonim7Point083Degrees() { * @see #ZENITH_13_POINT_24 * @see #getBainHasmashosRT58Point5Minutes() */ - public Date getBainHasmashosRT13Point24Degrees() { + public Long getBainHasmashosRT13Point24Degrees() { return getSunsetOffsetByDegrees(ZENITH_13_POINT_24); } @@ -2158,7 +2157,7 @@ public Date getBainHasmashosRT13Point24Degrees() { * documentation. * */ - public Date getBainHasmashosRT58Point5Minutes() { + public Long getBainHasmashosRT58Point5Minutes() { return getTimeOffset(getElevationAdjustedSunset(), 58.5 * MINUTE_MILLIS); } @@ -2173,7 +2172,7 @@ public Date getBainHasmashosRT58Point5Minutes() { * documentation. * @see #getTzaisGeonim7Point083Degrees() */ - public Date getBainHasmashosRT13Point5MinutesBefore7Point083Degrees() { + public Long getBainHasmashosRT13Point5MinutesBefore7Point083Degrees() { return getTimeOffset(getSunsetOffsetByDegrees(ZENITH_7_POINT_083), -13.5 * MINUTE_MILLIS); } @@ -2189,14 +2188,14 @@ public Date getBainHasmashosRT13Point5MinutesBefore7Point083Degrees() { * calculation, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getBainHasmashosRT2Stars() { - Date alos19Point8 = getAlos19Point8Degrees(); - Date sunrise = getElevationAdjustedSunrise(); + public Long getBainHasmashosRT2Stars() { + Long alos19Point8 = getAlos19Point8Degrees(); + Long sunrise = getElevationAdjustedSunrise(); if (alos19Point8 == null || sunrise == null) { return null; } - return getTimeOffset(getElevationAdjustedSunset(), (sunrise.getTime() - alos19Point8.getTime()) * (5 / 18d)); + return getTimeOffset(getElevationAdjustedSunset(), (sunrise - alos19Point8) * (5 / 18d)); } /** @@ -2211,7 +2210,7 @@ public Date getBainHasmashosRT2Stars() { * documentation. * @see #getBainHasmashosYereim3Point05Degrees() */ - public Date getBainHasmashosYereim18Minutes() { + public Long getBainHasmashosYereim18Minutes() { return getTimeOffset(getElevationAdjustedSunset(), -18 * MINUTE_MILLIS); } @@ -2244,7 +2243,7 @@ public Date getBainHasmashosYereim18Minutes() { * @see #getBainHasmashosYereim2Point8Degrees() * @see #getBainHasmashosYereim2Point1Degrees() */ - public Date getBainHasmashosYereim3Point05Degrees() { + public Long getBainHasmashosYereim3Point05Degrees() { return getSunsetOffsetByDegrees(ZENITH_MINUS_3_POINT_05); } @@ -2261,7 +2260,7 @@ public Date getBainHasmashosYereim3Point05Degrees() { * * @see #getBainHasmashosYereim2Point8Degrees() */ - public Date getBainHasmashosYereim16Point875Minutes() { + public Long getBainHasmashosYereim16Point875Minutes() { return getTimeOffset(getElevationAdjustedSunset(), -16.875 * MINUTE_MILLIS); } @@ -2285,7 +2284,7 @@ public Date getBainHasmashosYereim16Point875Minutes() { * @see #getBainHasmashosYereim3Point05Degrees() * @see #getBainHasmashosYereim2Point1Degrees() */ - public Date getBainHasmashosYereim2Point8Degrees() { + public Long getBainHasmashosYereim2Point8Degrees() { return getSunsetOffsetByDegrees(ZENITH_MINUS_2_POINT_8); } @@ -2302,7 +2301,7 @@ public Date getBainHasmashosYereim2Point8Degrees() { * * @see #getBainHasmashosYereim2Point1Degrees() */ - public Date getBainHasmashosYereim13Point5Minutes() { + public Long getBainHasmashosYereim13Point5Minutes() { return getTimeOffset(getElevationAdjustedSunset(), -13.5 * MINUTE_MILLIS); } @@ -2326,7 +2325,7 @@ public Date getBainHasmashosYereim13Point5Minutes() { * @see #getBainHasmashosYereim2Point8Degrees() * @see #getBainHasmashosYereim3Point05Degrees() */ - public Date getBainHasmashosYereim2Point1Degrees() { + public Long getBainHasmashosYereim2Point1Degrees() { return getSunsetOffsetByDegrees(ZENITH_MINUS_2_POINT_1); } @@ -2337,7 +2336,7 @@ public Date getBainHasmashosYereim2Point1Degrees() { * @return the Date representing the time when the sun is 3.7° below sea level. * @see #ZENITH_3_POINT_7 */ - public Date getTzaisGeonim3Point7Degrees() { + public Long getTzaisGeonim3Point7Degrees() { return getSunsetOffsetByDegrees(ZENITH_3_POINT_7); } @@ -2348,7 +2347,7 @@ public Date getTzaisGeonim3Point7Degrees() { * @return the Date representing the time when the sun is 3.8° below sea level. * @see #ZENITH_3_POINT_8 */ - public Date getTzaisGeonim3Point8Degrees() { + public Long getTzaisGeonim3Point8Degrees() { return getSunsetOffsetByDegrees(ZENITH_3_POINT_8); } @@ -2362,7 +2361,7 @@ public Date getTzaisGeonim3Point8Degrees() { * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_5_POINT_95 */ - public Date getTzaisGeonim5Point95Degrees() { + public Long getTzaisGeonim5Point95Degrees() { return getSunsetOffsetByDegrees(ZENITH_5_POINT_95); } @@ -2378,7 +2377,7 @@ public Date getTzaisGeonim5Point95Degrees() { * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_3_POINT_65 */ - public Date getTzaisGeonim3Point65Degrees() { + public Long getTzaisGeonim3Point65Degrees() { return getSunsetOffsetByDegrees(ZENITH_3_POINT_65); } @@ -2396,7 +2395,7 @@ public Date getTzaisGeonim3Point65Degrees() { * documentation. * @see #ZENITH_3_POINT_676 */ - public Date getTzaisGeonim3Point676Degrees() { + public Long getTzaisGeonim3Point676Degrees() { return getSunsetOffsetByDegrees(ZENITH_3_POINT_676); } @@ -2412,7 +2411,7 @@ public Date getTzaisGeonim3Point676Degrees() { * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_4_POINT_61 */ - public Date getTzaisGeonim4Point61Degrees() { + public Long getTzaisGeonim4Point61Degrees() { return getSunsetOffsetByDegrees(ZENITH_4_POINT_61); } @@ -2428,7 +2427,7 @@ public Date getTzaisGeonim4Point61Degrees() { * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_4_POINT_37 */ - public Date getTzaisGeonim4Point37Degrees() { + public Long getTzaisGeonim4Point37Degrees() { return getSunsetOffsetByDegrees(ZENITH_4_POINT_37); } @@ -2446,7 +2445,7 @@ public Date getTzaisGeonim4Point37Degrees() { * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_5_POINT_88 */ - public Date getTzaisGeonim5Point88Degrees() { + public Long getTzaisGeonim5Point88Degrees() { return getSunsetOffsetByDegrees(ZENITH_5_POINT_88); } @@ -2463,7 +2462,7 @@ public Date getTzaisGeonim5Point88Degrees() { * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_4_POINT_8 */ - public Date getTzaisGeonim4Point8Degrees() { + public Long getTzaisGeonim4Point8Degrees() { return getSunsetOffsetByDegrees(ZENITH_4_POINT_8); } @@ -2484,7 +2483,7 @@ public Date getTzaisGeonim4Point8Degrees() { * documentation. * @see #ZENITH_6_POINT_45 */ - public Date getTzaisGeonim6Point45Degrees() { + public Long getTzaisGeonim6Point45Degrees() { return getSunsetOffsetByDegrees(ZENITH_6_POINT_45); } @@ -2513,7 +2512,7 @@ public Date getTzaisGeonim6Point45Degrees() { * documentation. * @see #ZENITH_7_POINT_083 */ - public Date getTzaisGeonim7Point083Degrees() { + public Long getTzaisGeonim7Point083Degrees() { return getSunsetOffsetByDegrees(ZENITH_7_POINT_083); } @@ -2542,7 +2541,7 @@ public Date getTzaisGeonim7Point083Degrees() { * documentation. * @see #ZENITH_7_POINT_67 */ - public Date getTzaisGeonim7Point67Degrees() { + public Long getTzaisGeonim7Point67Degrees() { return getSunsetOffsetByDegrees(ZENITH_7_POINT_67); } @@ -2556,7 +2555,7 @@ public Date getTzaisGeonim7Point67Degrees() { * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_8_POINT_5 */ - public Date getTzaisGeonim8Point5Degrees() { + public Long getTzaisGeonim8Point5Degrees() { return getSunsetOffsetByDegrees(ZENITH_8_POINT_5); } @@ -2570,7 +2569,7 @@ public Date getTzaisGeonim8Point5Degrees() { * the Antarctic Circle where the sun may not reach low enough below the horizon for this calculation, a * null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getTzaisGeonim9Point3Degrees() { + public Long getTzaisGeonim9Point3Degrees() { return getSunsetOffsetByDegrees(ZENITH_9_POINT_3); } @@ -2592,7 +2591,7 @@ public Date getTzaisGeonim9Point3Degrees() { * * @see #getTzais60() */ - public Date getTzaisGeonim9Point75Degrees() { + public Long getTzaisGeonim9Point75Degrees() { return getSunsetOffsetByDegrees(ZENITH_9_POINT_75); } @@ -2613,7 +2612,7 @@ public Date getTzaisGeonim9Point75Degrees() { * @see #getPlagHamincha60Minutes() * @see #getShaahZmanis60Minutes() */ - public Date getTzais60() { + public Long getTzais60() { return getTimeOffset(getElevationAdjustedSunset(), 60 * MINUTE_MILLIS); } @@ -2633,7 +2632,7 @@ public Date getTzais60() { * @see #getAteretTorahSunsetOffset() * @see #setAteretTorahSunsetOffset(double) */ - public Date getTzaisAteretTorah() { + public Long getTzaisAteretTorah() { return getTimeOffset(getElevationAdjustedSunset(), getAteretTorahSunsetOffset() * MINUTE_MILLIS); } @@ -2684,7 +2683,7 @@ public void setAteretTorahSunsetOffset(double ateretTorahSunsetOffset) { * @see #setAteretTorahSunsetOffset(double) * @see #getShaahZmanisAteretTorah() */ - public Date getSofZmanShmaAteretTorah() { + public Long getSofZmanShmaAteretTorah() { return getSofZmanShma(getAlos72Zmanis(), getTzaisAteretTorah()); } @@ -2707,7 +2706,7 @@ public Date getSofZmanShmaAteretTorah() { * @see #getShaahZmanisAteretTorah() * @see #setAteretTorahSunsetOffset(double) */ - public Date getSofZmanTfilahAteretTorah() { + public Long getSofZmanTfilahAteretTorah() { return getSofZmanTfila(getAlos72Zmanis(), getTzaisAteretTorah()); } @@ -2735,7 +2734,7 @@ public Date getSofZmanTfilahAteretTorah() { * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaGedolaAteretTorah() { + public Long getMinchaGedolaAteretTorah() { return getMinchaGedola(getAlos72Zmanis(), getTzaisAteretTorah()); } @@ -2762,7 +2761,7 @@ public Date getMinchaGedolaAteretTorah() { * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaKetanaAteretTorah() { + public Long getMinchaKetanaAteretTorah() { return getMinchaKetana(getAlos72Zmanis(), getTzaisAteretTorah()); } @@ -2784,7 +2783,7 @@ public Date getMinchaKetanaAteretTorah() { * @see #setAteretTorahSunsetOffset(double) * @see #getAteretTorahSunsetOffset() */ - public Date getPlagHaminchaAteretTorah() { + public Long getPlagHaminchaAteretTorah() { return getPlagHamincha(getAlos72Zmanis(), getTzaisAteretTorah()); } @@ -2806,7 +2805,7 @@ public Date getPlagHaminchaAteretTorah() { * documentation. * @see #getAlos72Zmanis() */ - // private Date getMesheyakirAteretTorah(double minutes) { + // private Long getMesheyakirAteretTorah(double minutes) { // return getTimeOffset(getAlos72Zmanis(), minutes * MINUTE_MILLIS); // } @@ -2826,7 +2825,7 @@ public Date getPlagHaminchaAteretTorah() { * documentation. * @see #getAlos72Zmanis() */ - public Date getTzais72Zmanis() { + public Long getTzais72Zmanis() { return getZmanisBasedOffset(1.2); } @@ -2842,7 +2841,7 @@ public Date getTzais72Zmanis() { * a null will be returned. A null will also be returned if 0 is passed in, since we can't tell if it is sunrise * or sunset based. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - private Date getZmanisBasedOffset(double hours) { + private Long getZmanisBasedOffset(double hours) { long shaahZmanis = getShaahZmanisGra(); if (shaahZmanis == Long.MIN_VALUE || hours == 0) { return null; @@ -2866,7 +2865,7 @@ private Date getZmanisBasedOffset(double hours) { * documentation. * @see #getAlos90Zmanis() */ - public Date getTzais90Zmanis() { + public Long getTzais90Zmanis() { return getZmanisBasedOffset(1.5); } @@ -2880,7 +2879,7 @@ public Date getTzais90Zmanis() { * documentation. * @see #getAlos96Zmanis() */ - public Date getTzais96Zmanis() { + public Long getTzais96Zmanis() { return getZmanisBasedOffset(1.6); } @@ -2899,7 +2898,7 @@ public Date getTzais96Zmanis() { * @see #getTzais19Point8Degrees() * @see #getAlos90() */ - public Date getTzais90() { + public Long getTzais90() { return getTimeOffset(getElevationAdjustedSunset(), 90 * MINUTE_MILLIS); } @@ -2925,7 +2924,7 @@ public Date getTzais90() { * @see #getAlos120() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getTzais120() { + public Long getTzais120() { return getTimeOffset(getElevationAdjustedSunset(), 120 * MINUTE_MILLIS); } @@ -2948,7 +2947,7 @@ public Date getTzais120() { * @see #getTzais26Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getTzais120Zmanis() { + public Long getTzais120Zmanis() { return getZmanisBasedOffset(2.0); } @@ -2972,7 +2971,7 @@ public Date getTzais120Zmanis() { * @see #getTzais72() * @see #getAlos16Point1Degrees() for more information on this calculation. */ - public Date getTzais16Point1Degrees() { + public Long getTzais16Point1Degrees() { return getSunsetOffsetByDegrees(ZENITH_16_POINT_1); } @@ -2995,7 +2994,7 @@ public Date getTzais16Point1Degrees() { * @see #getAlos26Degrees() */ @Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version - public Date getTzais26Degrees() { + public Long getTzais26Degrees() { return getSunsetOffsetByDegrees(ZENITH_26_DEGREES); } @@ -3008,7 +3007,7 @@ public Date getTzais26Degrees() { * explanation on top of the {@link AstronomicalCalendar} documentation. * @see #getAlos18Degrees() */ - public Date getTzais18Degrees() { + public Long getTzais18Degrees() { return getSunsetOffsetByDegrees(ASTRONOMICAL_ZENITH); } @@ -3022,7 +3021,7 @@ public Date getTzais18Degrees() { * @see #getTzais90() * @see #getAlos19Point8Degrees() */ - public Date getTzais19Point8Degrees() { + public Long getTzais19Point8Degrees() { return getSunsetOffsetByDegrees(ZENITH_19_POINT_8); } @@ -3036,7 +3035,7 @@ public Date getTzais19Point8Degrees() { * documentation. * @see #getAlos96() */ - public Date getTzais96() { + public Long getTzais96() { return getTimeOffset(getElevationAdjustedSunset(), 96 * MINUTE_MILLIS); } @@ -3058,7 +3057,7 @@ public Date getTzais96() { * @return the Date representing the local chatzos * @see GeoLocation#getLocalMeanTimeOffset() */ - public Date getFixedLocalChatzos() { + public Long getFixedLocalChatzos() { return getTimeOffset(getDateFromTime(12.0 - getGeoLocation().getTimeZone().getRawOffset() / (double) HOUR_MILLIS, true), -getGeoLocation().getLocalMeanTimeOffset()); } @@ -3090,7 +3089,7 @@ public Date getFixedLocalChatzos() { * This will likely be removed in v3.0. */ @Deprecated // (since="2.4.0", forRemoval=true) // add back once Java 9 is the minimum supported version - public Date getSofZmanShmaFixedLocal() { + public Long getSofZmanShmaFixedLocal() { return getTimeOffset(getFixedLocalChatzos(), -180 * MINUTE_MILLIS); } @@ -3117,7 +3116,7 @@ public Date getSofZmanShmaFixedLocal() { * clock hours. This will likely be removed in v3.0. */ @Deprecated // (since="2.4.0", forRemoval=true) // add back once Java 9 is the minimum supported version - public Date getSofZmanTfilaFixedLocal() { + public Long getSofZmanTfilaFixedLocal() { return getTimeOffset(getFixedLocalChatzos(), -120 * MINUTE_MILLIS); } @@ -3141,10 +3140,10 @@ public Date getSofZmanTfilaFixedLocal() { * @return the Date representing the moment halfway between molad and molad. If the time occurs between * alos and tzais, alos will be returned * @see #getSofZmanKidushLevanaBetweenMoldos() - * @see #getSofZmanKidushLevana15Days(Date, Date) + * @see #getSofZmanKidushLevana15Days(Long, Long) * @see JewishCalendar#getSofZmanKidushLevanaBetweenMoldos() */ - public Date getSofZmanKidushLevanaBetweenMoldos(Date alos, Date tzais) { + public Long getSofZmanKidushLevanaBetweenMoldos(Long alos, Long tzais) { JewishCalendar jewishCalendar = new JewishCalendar(); jewishCalendar.setGregorianDate(getCalendar().get(Calendar.YEAR), getCalendar().get(Calendar.MONTH), getCalendar().get(Calendar.DAY_OF_MONTH)); @@ -3178,12 +3177,12 @@ public Date getSofZmanKidushLevanaBetweenMoldos(Date alos, Date tzais) { * alos or tzais are null. * @return the molad based time. If the zman does not occur during the current date, null will be returned. */ - private Date getMoladBasedTime(Date moladBasedTime, Date alos, Date tzais, boolean techila) { - Date lastMidnight = getMidnightLastNight(); - Date midnightTonigh = getMidnightTonight(); - if(!(moladBasedTime.before(lastMidnight) || moladBasedTime.after(midnightTonigh))){ + private Long getMoladBasedTime(Long moladBasedTime, Long alos, Long tzais, boolean techila) { + Long lastMidnight = getMidnightLastNight(); + Long midnightTonight = getMidnightTonight(); + if (((moladBasedTime >= lastMidnight) && (moladBasedTime <= midnightTonight))) { if(alos != null || tzais != null) { - if(techila && !(moladBasedTime.before(tzais) || moladBasedTime.after(alos))){ + if(techila && ((moladBasedTime >= tzais) && (moladBasedTime <= alos))) { return tzais; } else { return alos; @@ -3200,15 +3199,15 @@ private Date getMoladBasedTime(Date moladBasedTime, Date alos, Date tzais, boole * halfway between molad and molad. This adds half the 29 days, 12 hours and 793 chalakim time between * molad and molad (14 days, 18 hours, 22 minutes and 666 milliseconds) to the month's molad. * The sof zman Kiddush Levana will be returned even if it occurs during the day. To limit the time to between - * tzais and alos, see {@link #getSofZmanKidushLevanaBetweenMoldos(Date, Date)}. + * tzais and alos, see {@link #getSofZmanKidushLevanaBetweenMoldos(Long, Long)}. * * @return the Date representing the moment halfway between molad and molad. If the time occurs between * alos and tzais, alos will be returned - * @see #getSofZmanKidushLevanaBetweenMoldos(Date, Date) + * @see #getSofZmanKidushLevanaBetweenMoldos(Long, Long) * @see #getSofZmanKidushLevana15Days() * @see JewishCalendar#getSofZmanKidushLevanaBetweenMoldos() */ - public Date getSofZmanKidushLevanaBetweenMoldos() { + public Long getSofZmanKidushLevanaBetweenMoldos() { return getSofZmanKidushLevanaBetweenMoldos(null, null); } @@ -3217,7 +3216,7 @@ public Date getSofZmanKidushLevanaBetweenMoldos() { * opinion brought down in the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the * Rema who brings down the opinion of the Maharil's of calculating - * {@link #getSofZmanKidushLevanaBetweenMoldos(Date, Date) half way between molad and molad} is of + * {@link #getSofZmanKidushLevanaBetweenMoldos(Long, Long) half way between molad and molad} is of * the opinion that the Mechaber agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject, * see Rabbi Dovid Heber's very detailed write-up in Siman Daled (chapter 4) of Shaarei Zmanim. If the time of sof zman Kiddush Levana occurs during @@ -3236,10 +3235,10 @@ public Date getSofZmanKidushLevanaBetweenMoldos() { * @return the Date representing the moment 15 days after the molad. If the time occurs between alos and * tzais, alos will be returned * - * @see #getSofZmanKidushLevanaBetweenMoldos(Date, Date) + * @see #getSofZmanKidushLevanaBetweenMoldos(Long, Long) * @see JewishCalendar#getSofZmanKidushLevana15Days() */ - public Date getSofZmanKidushLevana15Days(Date alos, Date tzais) { + public Long getSofZmanKidushLevana15Days(Long alos, Long tzais) { JewishCalendar jewishCalendar = new JewishCalendar(); jewishCalendar.setGregorianDate(getCalendar().get(Calendar.YEAR), getCalendar().get(Calendar.MONTH), getCalendar().get(Calendar.DAY_OF_MONTH)); @@ -3258,21 +3257,21 @@ public Date getSofZmanKidushLevana15Days(Date alos, Date tzais) { * the Shulchan Aruch (Orach Chaim 426). It should be noted that some opinions hold that the * Rema who brings down the opinion of the Maharil's of calculating - * {@link #getSofZmanKidushLevanaBetweenMoldos(Date, Date) half way between molad and molad} is of + * {@link #getSofZmanKidushLevanaBetweenMoldos(Long, Long) half way between molad and molad} is of * the opinion that the Mechaber agrees to his opinion. Also see the Aruch Hashulchan. For additional details on the subject, * See Rabbi Dovid Heber's very detailed write-up in Siman Daled (chapter 4) of Shaarei * Zmanim. The sof zman Kiddush Levana will be returned even if it occurs during the day. To limit the time to - * between tzais and alos, see {@link #getSofZmanKidushLevana15Days(Date, Date)}. + * between tzais and alos, see {@link #getSofZmanKidushLevana15Days(Long, Long)}. * * @return the Date representing the moment 15 days after the molad. If the time occurs between * alos and tzais, alos will be returned * - * @see #getSofZmanKidushLevana15Days(Date, Date) + * @see #getSofZmanKidushLevana15Days(Long, Long) * @see #getSofZmanKidushLevanaBetweenMoldos() * @see JewishCalendar#getSofZmanKidushLevana15Days() * */ - public Date getSofZmanKidushLevana15Days() { + public Long getSofZmanKidushLevana15Days() { return getSofZmanKidushLevana15Days(null, null); } @@ -3280,14 +3279,14 @@ public Date getSofZmanKidushLevana15Days() { * Returns the earliest time of Kiddush Levana according to Rabbeinu Yonah's opinion that it can be said 3 days after the * molad. The time will be returned even if it occurs during the day when Kiddush Levana can't be said. - * Use {@link #getTchilasZmanKidushLevana3Days(Date, Date)} if you want to limit the time to night hours. + * Use {@link #getTchilasZmanKidushLevana3Days(Long, Long)} if you want to limit the time to night hours. * * @return the Date representing the moment 3 days after the molad. - * @see #getTchilasZmanKidushLevana3Days(Date, Date) + * @see #getTchilasZmanKidushLevana3Days(Long, Long) * @see #getTchilasZmanKidushLevana7Days() * @see JewishCalendar#getTchilasZmanKidushLevana3Days() */ - public Date getTchilasZmanKidushLevana3Days() { + public Long getTchilasZmanKidushLevana3Days() { return getTchilasZmanKidushLevana3Days(null, null); } @@ -3310,10 +3309,10 @@ public Date getTchilasZmanKidushLevana3Days() { * @return the Date representing the moment 3 days after the molad. If the time occurs between alos and * tzais, tzais will be returned * @see #getTchilasZmanKidushLevana3Days() - * @see #getTchilasZmanKidushLevana7Days(Date, Date) + * @see #getTchilasZmanKidushLevana7Days(Long, Long) * @see JewishCalendar#getTchilasZmanKidushLevana3Days() */ - public Date getTchilasZmanKidushLevana3Days(Date alos, Date tzais) { + public Long getTchilasZmanKidushLevana3Days(Long alos, Long tzais) { JewishCalendar jewishCalendar = new JewishCalendar(); jewishCalendar.setGregorianDate(getCalendar().get(Calendar.YEAR), getCalendar().get(Calendar.MONTH), getCalendar().get(Calendar.DAY_OF_MONTH)); @@ -3327,7 +3326,7 @@ public Date getTchilasZmanKidushLevana3Days(Date alos, Date tzais) { return null; } - Date zman = getMoladBasedTime(jewishCalendar.getTchilasZmanKidushLevana3Days(), alos, tzais, true); + Long zman = getMoladBasedTime(jewishCalendar.getTchilasZmanKidushLevana3Days(), alos, tzais, true); //Get the following month's zman kiddush Levana for the extreme case of Rapa Iti in French Polynesia on Dec 2027 when // kiddush Levana can be said on Rosh Chodesh (the evening of the 30th). See Rabbi Dovid Heber's Shaarei Zmanim chapter 4 (page 32) @@ -3347,10 +3346,10 @@ public Date getTchilasZmanKidushLevana3Days(Date alos, Date tzais) { * @return the Date representing the moment of the molad. If the molad does not occur on this day, a null will be returned. * * @see #getTchilasZmanKidushLevana3Days() - * @see #getTchilasZmanKidushLevana7Days(Date, Date) + * @see #getTchilasZmanKidushLevana7Days(Long, Long) * @see JewishCalendar#getMoladAsDate() */ - public Date getZmanMolad() { + public Long getZmanMolad() { JewishCalendar jewishCalendar = new JewishCalendar(); jewishCalendar.setGregorianDate(getCalendar().get(Calendar.YEAR), getCalendar().get(Calendar.MONTH), getCalendar().get(Calendar.DAY_OF_MONTH)); @@ -3361,7 +3360,7 @@ public Date getZmanMolad() { if(jewishCalendar.getJewishDayOfMonth() > 2 && jewishCalendar.getJewishDayOfMonth() < 27) { return null; } - Date molad = getMoladBasedTime(jewishCalendar.getMoladAsDate(), null, null, true); + Long molad = getMoladBasedTime(jewishCalendar.getMoladAsDate(), null, null, true); // deal with molad that happens on the end of the previous month if(molad == null && jewishCalendar.getJewishDayOfMonth() > 26) { @@ -3373,32 +3372,32 @@ public Date getZmanMolad() { /** * Used by Molad based zmanim to determine if zmanim occur during the current day. - * @see #getMoladBasedTime(Date, Date, Date, boolean) + * @see #getMoladBasedTime(Long, Long, Long, boolean) * @return previous midnight */ - private Date getMidnightLastNight() { + private Long getMidnightLastNight() { Calendar midnight = (Calendar)getCalendar().clone(); // reset hour, minutes, seconds and millis midnight.set(Calendar.HOUR_OF_DAY, 0); midnight.set(Calendar.MINUTE, 0); midnight.set(Calendar.SECOND, 0); midnight.set(Calendar.MILLISECOND, 0); - return midnight.getTime(); + return midnight.getTimeInMillis(); } /** * Used by Molad based zmanim to determine if zmanim occur during the current day. - * @see #getMoladBasedTime(Date, Date, Date, boolean) + * @see #getMoladBasedTime(Long, Long, Long, boolean) * @return following midnight */ - private Date getMidnightTonight() { + private Long getMidnightTonight() { Calendar midnight = (Calendar)getCalendar().clone(); midnight.add(Calendar.DAY_OF_YEAR, 1);//roll to tonight midnight.set(Calendar.HOUR_OF_DAY, 0); midnight.set(Calendar.MINUTE, 0); midnight.set(Calendar.SECOND, 0); midnight.set(Calendar.MILLISECOND, 0); - return midnight.getTime(); + return midnight.getTimeInMillis(); } /** @@ -3418,11 +3417,11 @@ private Date getMidnightTonight() { * * @return the Date representing the moment 7 days after the molad. If the time occurs between alos and * tzais, tzais will be returned - * @see #getTchilasZmanKidushLevana3Days(Date, Date) + * @see #getTchilasZmanKidushLevana3Days(Long, Long) * @see #getTchilasZmanKidushLevana7Days() * @see JewishCalendar#getTchilasZmanKidushLevana7Days() */ - public Date getTchilasZmanKidushLevana7Days(Date alos, Date tzais) { + public Long getTchilasZmanKidushLevana7Days(Long alos, Long tzais) { JewishCalendar jewishCalendar = new JewishCalendar(); jewishCalendar.setGregorianDate(getCalendar().get(Calendar.YEAR), getCalendar().get(Calendar.MONTH), getCalendar().get(Calendar.DAY_OF_MONTH)); @@ -3442,14 +3441,14 @@ public Date getTchilasZmanKidushLevana7Days(Date alos, Date tzais) { /** * Returns the earliest time of Kiddush Levana according to the opinions that it should not be said until 7 * days after the molad. The time will be returned even if it occurs during the day when Kiddush Levana - * can't be recited. Use {@link #getTchilasZmanKidushLevana7Days(Date, Date)} if you want to limit the time to night hours. + * can't be recited. Use {@link #getTchilasZmanKidushLevana7Days(Long, Long)} if you want to limit the time to night hours. * * @return the Date representing the moment 7 days after the molad regardless of it is day or night. - * @see #getTchilasZmanKidushLevana7Days(Date, Date) + * @see #getTchilasZmanKidushLevana7Days(Long, Long) * @see JewishCalendar#getTchilasZmanKidushLevana7Days() * @see #getTchilasZmanKidushLevana3Days() */ - public Date getTchilasZmanKidushLevana7Days() { + public Long getTchilasZmanKidushLevana7Days() { return getTchilasZmanKidushLevana7Days(null, null); } @@ -3468,7 +3467,7 @@ public Date getTchilasZmanKidushLevana7Days() { * not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getSofZmanAchilasChametzGRA() { + public Long getSofZmanAchilasChametzGRA() { return getSofZmanTfilaGRA(); } @@ -3489,7 +3488,7 @@ public Date getSofZmanAchilasChametzGRA() { * @see #getAlos72() * @see #getSofZmanTfilaMGA72Minutes() */ - public Date getSofZmanAchilasChametzMGA72Minutes() { + public Long getSofZmanAchilasChametzMGA72Minutes() { return getSofZmanTfilaMGA72Minutes(); } @@ -3511,7 +3510,7 @@ public Date getSofZmanAchilasChametzMGA72Minutes() { * @see #getAlos16Point1Degrees() * @see #getSofZmanTfilaMGA16Point1Degrees() */ - public Date getSofZmanAchilasChametzMGA16Point1Degrees() { + public Long getSofZmanAchilasChametzMGA16Point1Degrees() { return getSofZmanTfilaMGA16Point1Degrees(); } @@ -3528,7 +3527,7 @@ public Date getSofZmanAchilasChametzMGA16Point1Degrees() { * the sun does not rise, and one where it does not set, a null will be returned. See detailed explanation on * top of the {@link AstronomicalCalendar} documentation. */ - public Date getSofZmanBiurChametzGRA() { + public Long getSofZmanBiurChametzGRA() { return getTimeOffset(getElevationAdjustedSunrise(), getShaahZmanisGra() * 5); } @@ -3548,7 +3547,7 @@ public Date getSofZmanBiurChametzGRA() { * @see #getShaahZmanisMGA() * @see #getAlos72() */ - public Date getSofZmanBiurChametzMGA72Minutes() { + public Long getSofZmanBiurChametzMGA72Minutes() { return getTimeOffset(getAlos72(), getShaahZmanisMGA() * 5); } @@ -3569,7 +3568,7 @@ public Date getSofZmanBiurChametzMGA72Minutes() { * @see #getShaahZmanis16Point1Degrees() * @see #getAlos16Point1Degrees() */ - public Date getSofZmanBiurChametzMGA16Point1Degrees() { + public Long getSofZmanBiurChametzMGA16Point1Degrees() { return getTimeOffset(getAlos16Point1Degrees(), getShaahZmanis16Point1Degrees() * 5); } @@ -3583,11 +3582,11 @@ public Date getSofZmanBiurChametzMGA16Point1Degrees() { * does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getSolarMidnight() { + public Long getSolarMidnight() { ZmanimCalendar clonedCal = (ZmanimCalendar) clone(); clonedCal.getCalendar().add(Calendar.DAY_OF_MONTH, 1); - Date sunset = getSeaLevelSunset(); - Date sunrise = clonedCal.getSeaLevelSunrise(); + Long sunset = getSeaLevelSunset(); + Long sunrise = clonedCal.getSeaLevelSunrise(); return getTimeOffset(sunset, getTemporalHour(sunset, sunrise) * 6); } @@ -3625,7 +3624,7 @@ public Date getSolarMidnight() { * @see #getSunsetBaalHatanya() * @see #ZENITH_1_POINT_583 */ - private Date getSunriseBaalHatanya() { + private Long getSunriseBaalHatanya() { return getSunriseOffsetByDegrees(ZENITH_1_POINT_583); } @@ -3656,18 +3655,18 @@ private Date getSunriseBaalHatanya() { * @see #getSunriseBaalHatanya() * @see #ZENITH_1_POINT_583 */ - private Date getSunsetBaalHatanya() { + private Long getSunsetBaalHatanya() { return getSunsetOffsetByDegrees(ZENITH_1_POINT_583); } /** * A method that returns the Baal Hatanya's - * a shaah zmanis ({@link #getTemporalHour(Date, Date) temporal hour}). This forms the base for the + * a shaah zmanis ({@link #getTemporalHour(Long, Long) temporal hour}). This forms the base for the * Baal Hatanya's day based calculations that are calculated as a 1.583° dip below the horizon after sunset. * According to the Baal Hatanya, shkiah amiti, true (halachic) sunset, is when the top of the * sun's disk disappears from view at an elevation similar to the mountains of Eretz Yisrael. * This time is calculated as the point at which the center of the sun's disk is 1.583 degrees below the horizon. - * A method that returns a shaah zmanis ({@link #getTemporalHour(Date, Date) temporal hour}) calculated + * A method that returns a shaah zmanis ({@link #getTemporalHour(Long, Long) temporal hour}) calculated * based on the Baal Hatanya's netz * amiti and shkiah amiti using a dip of 1.583° below the sea level horizon. This calculation divides * the day based on the opinion of the Baal Hatanya that the day runs from {@link #getSunriseBaalHatanya() netz amiti} @@ -3681,7 +3680,7 @@ private Date getSunsetBaalHatanya() { * year where the sun does not rise, and one where it does not set, {@link Long#MIN_VALUE} will be returned. See * detailed explanation on top of the {@link AstronomicalCalendar} documentation. * - * @see #getTemporalHour(Date, Date) + * @see #getTemporalHour(Long, Long) * @see #getSunriseBaalHatanya() * @see #getSunsetBaalHatanya() * @see #ZENITH_1_POINT_583 @@ -3701,7 +3700,7 @@ public long getShaahZmanisBaalHatanya() { * low enough below the horizon for this calculation, a null will be returned. See detailed explanation on * top of the {@link AstronomicalCalendar} documentation. */ - public Date getAlosBaalHatanya() { + public Long getAlosBaalHatanya() { return getSunriseOffsetByDegrees(ZENITH_16_POINT_9); } @@ -3712,14 +3711,14 @@ public Date getAlosBaalHatanya() { * sunrise to sunset. This returns the time 3 * {@link #getShaahZmanisBaalHatanya()} after {@link #getSunriseBaalHatanya() * netz amiti (sunrise)}. * - * @see ZmanimCalendar#getSofZmanShma(Date, Date) + * @see ZmanimCalendar#getSofZmanShma(Long, Long) * @see #getShaahZmanisBaalHatanya() * @return the Date of the latest zman shema according to the Baal Hatanya. If the calculation * can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does * not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getSofZmanShmaBaalHatanya() { + public Long getSofZmanShmaBaalHatanya() { return getSofZmanShma(getSunriseBaalHatanya(), getSunsetBaalHatanya()); } @@ -3729,14 +3728,14 @@ public Date getSofZmanShmaBaalHatanya() { * calculated from sunrise to sunset. This returns the time 4 * {@link #getShaahZmanisBaalHatanya()} after * {@link #getSunriseBaalHatanya() netz amiti (sunrise)}. * - * @see ZmanimCalendar#getSofZmanTfila(Date, Date) + * @see ZmanimCalendar#getSofZmanTfila(Long, Long) * @see #getShaahZmanisBaalHatanya() * @return the Date of the latest zman tfilah. If the calculation can't be computed such as in * the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does * not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getSofZmanTfilaBaalHatanya() { + public Long getSofZmanTfilaBaalHatanya() { return getSofZmanTfila(getSunriseBaalHatanya(), getSunsetBaalHatanya()); } @@ -3754,7 +3753,7 @@ public Date getSofZmanTfilaBaalHatanya() { * and one where it does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getSofZmanAchilasChametzBaalHatanya() { + public Long getSofZmanAchilasChametzBaalHatanya() { return getSofZmanTfilaBaalHatanya(); } @@ -3770,7 +3769,7 @@ public Date getSofZmanAchilasChametzBaalHatanya() { * and one where it does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getSofZmanBiurChametzBaalHatanya() { + public Long getSofZmanBiurChametzBaalHatanya() { return getTimeOffset(getSunriseBaalHatanya(), getShaahZmanisBaalHatanya() * 5); } @@ -3786,7 +3785,7 @@ public Date getSofZmanBiurChametzBaalHatanya() { * on the opinion of the Baal Hatanya that the day is calculated from sunrise to sunset. This returns the time 6.5 * * {@link #getShaahZmanisBaalHatanya()} after {@link #getSunriseBaalHatanya() netz amiti ("real" sunrise)}. * - * @see #getMinchaGedola(Date, Date) + * @see #getMinchaGedola(Long, Long) * @see #getShaahZmanisBaalHatanya() * @see #getMinchaKetanaBaalHatanya() * @return the Date of the time of mincha gedola. If the calculation can't be computed such as @@ -3794,7 +3793,7 @@ public Date getSofZmanBiurChametzBaalHatanya() { * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaGedolaBaalHatanya() { + public Long getMinchaGedolaBaalHatanya() { return getMinchaGedola(getSunriseBaalHatanya(), getSunsetBaalHatanya()); } @@ -3809,7 +3808,7 @@ public Date getMinchaGedolaBaalHatanya() { * where the sun does not rise, and one where it does not set, a null will be returned. See detailed * explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getMinchaGedolaBaalHatanyaGreaterThan30() { + public Long getMinchaGedolaBaalHatanyaGreaterThan30() { if (getMinchaGedola30Minutes() == null || getMinchaGedolaBaalHatanya() == null) { return null; } else { @@ -3827,7 +3826,7 @@ public Date getMinchaGedolaBaalHatanyaGreaterThan30() { * day is calculated from sunrise to sunset. This returns the time 9.5 * {@link #getShaahZmanisBaalHatanya()} after {@link * #getSunriseBaalHatanya() netz amiti (sunrise)}. * - * @see #getMinchaKetana(Date, Date) + * @see #getMinchaKetana(Long, Long) * @see #getShaahZmanisBaalHatanya() * @see #getMinchaGedolaBaalHatanya() * @return the Date of the time of mincha ketana. If the calculation can't be computed such as @@ -3835,7 +3834,7 @@ public Date getMinchaGedolaBaalHatanyaGreaterThan30() { * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaKetanaBaalHatanya() { + public Long getMinchaKetanaBaalHatanya() { return getMinchaKetana(getSunriseBaalHatanya(), getSunsetBaalHatanya()); } @@ -3845,13 +3844,13 @@ public Date getMinchaKetanaBaalHatanya() { * from sunrise to sunset. This returns the time 10.75 * {@link #getShaahZmanisBaalHatanya()} after * {@link #getSunriseBaalHatanya() netz amiti (sunrise)}. * - * @see #getPlagHamincha(Date, Date) + * @see #getPlagHamincha(Long, Long) * @return the Date of the time of plag hamincha. If the calculation can't be computed such as * in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it * does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getPlagHaminchaBaalHatanya() { + public Long getPlagHaminchaBaalHatanya() { return getPlagHamincha(getSunriseBaalHatanya(), getSunsetBaalHatanya()); } @@ -3866,7 +3865,7 @@ public Date getPlagHaminchaBaalHatanya() { * top of the {@link AstronomicalCalendar} documentation. * @see #ZENITH_6_DEGREES */ - public Date getTzaisBaalHatanya() { + public Long getTzaisBaalHatanya() { return this.getSunsetOffsetByDegrees(ZENITH_6_DEGREES); } @@ -3894,12 +3893,12 @@ public Date getTzaisBaalHatanya() { * * @see ComplexZmanimCalendar#getFixedLocalChatzos() */ - public Date getFixedLocalChatzosBasedZmanim(Date startOfHalfDay, Date endOfHalfDay, double hours) { + public Long getFixedLocalChatzosBasedZmanim(Long startOfHalfDay, Long endOfHalfDay, double hours) { if (startOfHalfDay == null || endOfHalfDay == null) { return null; } - long shaahZmanis = (endOfHalfDay.getTime() - startOfHalfDay.getTime()) / 6; - return new Date((long)(startOfHalfDay.getTime() + shaahZmanis * hours)); + long shaahZmanis = (endOfHalfDay - startOfHalfDay) / 6; + return (long)(startOfHalfDay + shaahZmanis * hours); } /** @@ -3916,9 +3915,9 @@ public Date getFixedLocalChatzosBasedZmanim(Date startOfHalfDay, Date endOfHalfD * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #getAlos18Degrees() * @see #getFixedLocalChatzos() - * @see #getFixedLocalChatzosBasedZmanim(Date, Date, double) + * @see #getFixedLocalChatzosBasedZmanim(Long, Long, double) */ - public Date getSofZmanShmaMGA18DegreesToFixedLocalChatzos() { + public Long getSofZmanShmaMGA18DegreesToFixedLocalChatzos() { return getFixedLocalChatzosBasedZmanim(getAlos18Degrees(), getFixedLocalChatzos(), 3); } @@ -3936,9 +3935,9 @@ public Date getSofZmanShmaMGA18DegreesToFixedLocalChatzos() { * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #getAlos16Point1Degrees() * @see #getFixedLocalChatzos() - * @see #getFixedLocalChatzosBasedZmanim(Date, Date, double) + * @see #getFixedLocalChatzosBasedZmanim(Long, Long, double) */ - public Date getSofZmanShmaMGA16Point1DegreesToFixedLocalChatzos() { + public Long getSofZmanShmaMGA16Point1DegreesToFixedLocalChatzos() { return getFixedLocalChatzosBasedZmanim(getAlos16Point1Degrees(), getFixedLocalChatzos(), 3); } @@ -3957,9 +3956,9 @@ public Date getSofZmanShmaMGA16Point1DegreesToFixedLocalChatzos() { * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #getAlos90() * @see #getFixedLocalChatzos() - * @see #getFixedLocalChatzosBasedZmanim(Date, Date, double) + * @see #getFixedLocalChatzosBasedZmanim(Long, Long, double) */ - public Date getSofZmanShmaMGA90MinutesToFixedLocalChatzos() { + public Long getSofZmanShmaMGA90MinutesToFixedLocalChatzos() { return getFixedLocalChatzosBasedZmanim(getAlos90(), getFixedLocalChatzos(), 3); } @@ -3978,9 +3977,9 @@ public Date getSofZmanShmaMGA90MinutesToFixedLocalChatzos() { * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #getAlos72() * @see #getFixedLocalChatzos() - * @see #getFixedLocalChatzosBasedZmanim(Date, Date, double) + * @see #getFixedLocalChatzosBasedZmanim(Long, Long, double) */ - public Date getSofZmanShmaMGA72MinutesToFixedLocalChatzos() { + public Long getSofZmanShmaMGA72MinutesToFixedLocalChatzos() { return getFixedLocalChatzosBasedZmanim(getAlos72(), getFixedLocalChatzos(), 3); } @@ -3998,9 +3997,9 @@ public Date getSofZmanShmaMGA72MinutesToFixedLocalChatzos() { * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #getSunrise() * @see #getFixedLocalChatzos() - * @see #getFixedLocalChatzosBasedZmanim(Date, Date, double) + * @see #getFixedLocalChatzosBasedZmanim(Long, Long, double) */ - public Date getSofZmanShmaGRASunriseToFixedLocalChatzos() { + public Long getSofZmanShmaGRASunriseToFixedLocalChatzos() { return getFixedLocalChatzosBasedZmanim(getSunrise(), getFixedLocalChatzos(), 3); } @@ -4018,9 +4017,9 @@ public Date getSofZmanShmaGRASunriseToFixedLocalChatzos() { * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * @see #getSunrise() * @see #getFixedLocalChatzos() - * @see #getFixedLocalChatzosBasedZmanim(Date, Date, double) + * @see #getFixedLocalChatzosBasedZmanim(Long, Long, double) */ - public Date getSofZmanTfilaGRASunriseToFixedLocalChatzos() { + public Long getSofZmanTfilaGRASunriseToFixedLocalChatzos() { return getFixedLocalChatzosBasedZmanim(getSunrise(), getFixedLocalChatzos(), 4); } @@ -4039,7 +4038,7 @@ public Date getSofZmanTfilaGRASunriseToFixedLocalChatzos() { * @see #getFixedLocalChatzos() * @see #getMinchaKetanaGRAFixedLocalChatzosToSunset */ - public Date getMinchaGedolaGRAFixedLocalChatzos30Minutes() { + public Long getMinchaGedolaGRAFixedLocalChatzos30Minutes() { return getTimeOffset(getFixedLocalChatzos(), MINUTE_MILLIS * 30); } @@ -4059,7 +4058,7 @@ public Date getMinchaGedolaGRAFixedLocalChatzos30Minutes() { * @see #getFixedLocalChatzos() * @see #getMinchaGedolaGRAFixedLocalChatzos30Minutes */ - public Date getMinchaKetanaGRAFixedLocalChatzosToSunset() { + public Long getMinchaKetanaGRAFixedLocalChatzosToSunset() { return getFixedLocalChatzosBasedZmanim(getFixedLocalChatzos(), getSunset(), 3.5); } @@ -4079,7 +4078,7 @@ public Date getMinchaKetanaGRAFixedLocalChatzosToSunset() { * @see #getMinchaKetanaGRAFixedLocalChatzosToSunset * @see #getMinchaGedolaGRAFixedLocalChatzos30Minutes */ - public Date getPlagHaminchaGRAFixedLocalChatzosToSunset() { + public Long getPlagHaminchaGRAFixedLocalChatzosToSunset() { return getFixedLocalChatzosBasedZmanim(getFixedLocalChatzos(), getSunset(), 4.75); } @@ -4093,7 +4092,7 @@ public Date getPlagHaminchaGRAFixedLocalChatzosToSunset() { * a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getTzais50() { + public Long getTzais50() { return getTimeOffset(getElevationAdjustedSunset(), 50 * MINUTE_MILLIS); } @@ -4114,7 +4113,7 @@ public Date getTzais50() { * where the sun may not reach low enough below the horizon for this calculation, a null will be returned. * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getSamuchLeMinchaKetanaGRA() { + public Long getSamuchLeMinchaKetanaGRA() { return getSamuchLeMinchaKetana(getElevationAdjustedSunrise(), getElevationAdjustedSunset()); } @@ -4132,7 +4131,7 @@ public Date getSamuchLeMinchaKetanaGRA() { * where the sun may not reach low enough below the horizon for this calculation, a null will be returned. * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getSamuchLeMinchaKetana16Point1Degrees() { + public Long getSamuchLeMinchaKetana16Point1Degrees() { return getSamuchLeMinchaKetana(getAlos16Point1Degrees(), getTzais16Point1Degrees()); } @@ -4150,7 +4149,7 @@ public Date getSamuchLeMinchaKetana16Point1Degrees() { * where the sun may not reach low enough below the horizon for this calculation, a null will be returned. * See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getSamuchLeMinchaKetana72Minutes() { + public Long getSamuchLeMinchaKetana72Minutes() { return getSamuchLeMinchaKetana(getAlos72(), getTzais72()); } } diff --git a/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java b/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java index 379e5e68..f789f011 100644 --- a/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java @@ -16,7 +16,6 @@ package com.kosherjava.zmanim; import java.util.Calendar; -import java.util.Date; import com.kosherjava.zmanim.hebrewcalendar.JewishCalendar; import com.kosherjava.zmanim.util.AstronomicalCalculator; @@ -166,7 +165,7 @@ public void setUseElevation(boolean useElevation) { * {@link AstronomicalCalendar#getSunrise()} if it is true. * @see com.kosherjava.zmanim.AstronomicalCalendar#getSunrise() */ - protected Date getElevationAdjustedSunrise() { + protected Long getElevationAdjustedSunrise() { if(isUseElevation()) { return super.getSunrise(); } @@ -182,7 +181,7 @@ protected Date getElevationAdjustedSunrise() { * {@link AstronomicalCalendar#getSunset()} if it is true. * @see com.kosherjava.zmanim.AstronomicalCalendar#getSunset() */ - protected Date getElevationAdjustedSunset() { + protected Long getElevationAdjustedSunset() { if(isUseElevation()) { return super.getSunset(); } @@ -204,7 +203,7 @@ protected Date getElevationAdjustedSunset() { * @see #ZENITH_8_POINT_5 * ComplexZmanimCalendar#getTzaisGeonim8Point5Degrees() that returns an identical time to this generic tzais */ - public Date getTzais() { + public Long getTzais() { return getSunsetOffsetByDegrees(ZENITH_8_POINT_5); } @@ -225,7 +224,7 @@ public Date getTzais() { * low enough below the horizon for this calculation, a null will be returned. See detailed explanation on * top of the {@link AstronomicalCalendar} documentation. */ - public Date getAlosHashachar() { + public Long getAlosHashachar() { return getSunriseOffsetByDegrees(ZENITH_16_POINT_1); } @@ -242,7 +241,7 @@ public Date getAlosHashachar() { * a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getAlos72() { + public Long getAlos72() { return getTimeOffset(getElevationAdjustedSunrise(), -72 * MINUTE_MILLIS); } @@ -258,7 +257,7 @@ public Date getAlos72() { * where there is at least one day where the sun does not rise, and one where it does not set, a null will * be returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getChatzos() { + public Long getChatzos() { return getSunTransit(); } @@ -284,7 +283,7 @@ public Date getChatzos() { * a year where the sun does not rise, and one where it does not set, a null will be returned. See detailed * explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getSofZmanShma(Date startOfDay, Date endOfDay) { + public Long getSofZmanShma(Long startOfDay, Long endOfDay) { return getShaahZmanisBasedZman(startOfDay, endOfDay, 3); } @@ -297,7 +296,7 @@ public Date getSofZmanShma(Date startOfDay, Date endOfDay) { * sunset} or {@link #getSunrise() sunrise} to {@link #getSunset() sunset} (depending on the {@link #isUseElevation()} * setting). * - * @see #getSofZmanShma(Date, Date) + * @see #getSofZmanShma(Long, Long) * @see #getShaahZmanisGra() * @see #isUseElevation() * @see ComplexZmanimCalendar#getSofZmanShmaBaalHatanya() @@ -306,7 +305,7 @@ public Date getSofZmanShma(Date startOfDay, Date endOfDay) { * and one where it does not set, a null will be returned. See the detailed explanation on top of the {@link * AstronomicalCalendar} documentation. */ - public Date getSofZmanShmaGRA() { + public Long getSofZmanShmaGRA() { return getSofZmanShma(getElevationAdjustedSunrise(), getElevationAdjustedSunset()); } @@ -322,12 +321,12 @@ public Date getSofZmanShmaGRA() { * the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it * does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. - * @see #getSofZmanShma(Date, Date) + * @see #getSofZmanShma(Long, Long) * @see ComplexZmanimCalendar#getShaahZmanis72Minutes() * @see ComplexZmanimCalendar#getAlos72() * @see ComplexZmanimCalendar#getSofZmanShmaMGA72Minutes() that */ - public Date getSofZmanShmaMGA() { + public Long getSofZmanShmaMGA() { return getSofZmanShma(getAlos72(), getTzais72()); } @@ -346,7 +345,7 @@ public Date getSofZmanShmaMGA() { * and one where it does not set, a null will be returned See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getTzais72() { + public Long getTzais72() { return getTimeOffset(getElevationAdjustedSunset(), 72 * MINUTE_MILLIS); } @@ -355,7 +354,7 @@ public Date getTzais72() { * {@link #getSeaLevelSunset() sea level sunset}. This will return the time for any day of the week, since it can be * used to calculate candle lighting time for Yom Tov (mid-week holidays) as well. Elevation adjustments * are intentionally not performed by this method, but you can calculate it by passing the elevation adjusted sunset - * to {@link #getTimeOffset(Date, long)}. + * to {@link #getTimeOffset(Long, long)}. * * @return candle lighting time. If the calculation can't be computed such as in the Arctic Circle where there is at * least one day a year where the sun does not rise, and one where it does not set, a null will be returned. @@ -365,7 +364,7 @@ public Date getTzais72() { * @see #getCandleLightingOffset() * @see #setCandleLightingOffset(double) */ - public Date getCandleLighting() { + public Long getCandleLighting() { return getTimeOffset(getSeaLevelSunset(), -getCandleLightingOffset() * MINUTE_MILLIS); } @@ -391,7 +390,7 @@ public Date getCandleLighting() { * one day a year where the sun does not rise, and one where it does not set, a null will be returned. See * detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getSofZmanTfila(Date startOfDay, Date endOfDay) { + public Long getSofZmanTfila(Long startOfDay, Long endOfDay) { return getShaahZmanisBasedZman(startOfDay, endOfDay, 4); } @@ -404,7 +403,7 @@ public Date getSofZmanTfila(Date startOfDay, Date endOfDay) { * sunset} or {@link #getSunrise() sunrise} to {@link #getSunset() sunset} (depending on the {@link #isUseElevation()} * setting). * - * @see #getSofZmanTfila(Date, Date) + * @see #getSofZmanTfila(Long, Long) * @see #getShaahZmanisGra() * @see ComplexZmanimCalendar#getSofZmanTfilaBaalHatanya() * @return the Date of the latest zman tfilah. If the calculation can't be computed such as in @@ -412,7 +411,7 @@ public Date getSofZmanTfila(Date startOfDay, Date endOfDay) { * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getSofZmanTfilaGRA() { + public Long getSofZmanTfilaGRA() { return getSofZmanTfila(getElevationAdjustedSunrise(), getElevationAdjustedSunset()); } @@ -428,11 +427,11 @@ public Date getSofZmanTfilaGRA() { * the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it * does not set), a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. - * @see #getSofZmanTfila(Date, Date) + * @see #getSofZmanTfila(Long, Long) * @see #getShaahZmanisMGA() * @see #getAlos72() */ - public Date getSofZmanTfilaMGA() { + public Long getSofZmanTfilaMGA() { return getSofZmanTfila(getAlos72(), getTzais72()); } @@ -458,7 +457,7 @@ public Date getSofZmanTfilaMGA() { * at least one day a year where the sun does not rise, and one where it does not set, a null will be * returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getMinchaGedola(Date startOfDay, Date endOfDay) { + public Long getMinchaGedola(Long startOfDay, Long endOfDay) { return getShaahZmanisBasedZman(startOfDay, endOfDay, 6.5); } @@ -474,7 +473,7 @@ public Date getMinchaGedola(Date startOfDay, Date endOfDay) { * sunset} or {@link #getSunrise() sunrise} to {@link #getSunset() sunset} (depending on the {@link #isUseElevation()} * setting). * - * @see #getMinchaGedola(Date, Date) + * @see #getMinchaGedola(Long, Long) * @see #getShaahZmanisGra() * @see #getMinchaKetana() * @see ComplexZmanimCalendar#getMinchaGedolaBaalHatanya() @@ -483,13 +482,13 @@ public Date getMinchaGedola(Date startOfDay, Date endOfDay) { * not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaGedola() { + public Long getMinchaGedola() { return getMinchaGedola(getElevationAdjustedSunrise(), getElevationAdjustedSunset()); } /** * A generic method for calculating samuch lemincha ketana, / near mincha ketana time that is half - * an hour before {@link #getMinchaKetana(Date, Date)} or 9 * shaos zmaniyos (temporal hours) after the + * an hour before {@link #getMinchaKetana(Long, Long)} or 9 * shaos zmaniyos (temporal hours) after the * start of the day, calculated using the start and end of the day passed to this method. * The time from the start of day to the end of day are divided into 12 shaos zmaniyos (temporal hours), and * samuch lemincha ketana is calculated as 9 of those shaos zmaniyos after the beginning of the day. @@ -513,7 +512,7 @@ public Date getMinchaGedola() { * @see ComplexZmanimCalendar#getSamuchLeMinchaKetana16Point1Degrees() * @see ComplexZmanimCalendar#getSamuchLeMinchaKetana72Minutes() */ - public Date getSamuchLeMinchaKetana(Date startOfDay, Date endOfDay) { + public Long getSamuchLeMinchaKetana(Long startOfDay, Long endOfDay) { return getShaahZmanisBasedZman(startOfDay, endOfDay, 9); } @@ -541,7 +540,7 @@ public Date getSamuchLeMinchaKetana(Date startOfDay, Date endOfDay) { * returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. * */ - public Date getMinchaKetana(Date startOfDay, Date endOfDay) { + public Long getMinchaKetana(Long startOfDay, Long endOfDay) { return getShaahZmanisBasedZman(startOfDay, endOfDay, 9.5); } @@ -556,7 +555,7 @@ public Date getMinchaKetana(Date startOfDay, Date endOfDay) { * sunset} or {@link #getSunrise() sunrise} to {@link #getSunset() sunset} (depending on the {@link #isUseElevation()} * setting. * - * @see #getMinchaKetana(Date, Date) + * @see #getMinchaKetana(Long, Long) * @see #getShaahZmanisGra() * @see #getMinchaGedola() * @see ComplexZmanimCalendar#getMinchaKetanaBaalHatanya() @@ -565,7 +564,7 @@ public Date getMinchaKetana(Date startOfDay, Date endOfDay) { * not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getMinchaKetana() { + public Long getMinchaKetana() { return getMinchaKetana(getElevationAdjustedSunrise(), getElevationAdjustedSunset()); } @@ -589,7 +588,7 @@ public Date getMinchaKetana() { * at least one day a year where the sun does not rise, and one where it does not set, a null will be * returned. See detailed explanation on top of the {@link AstronomicalCalendar} documentation. */ - public Date getPlagHamincha(Date startOfDay, Date endOfDay) { + public Long getPlagHamincha(Long startOfDay, Long endOfDay) { return getShaahZmanisBasedZman(startOfDay, endOfDay, 10.75); } @@ -601,19 +600,19 @@ public Date getPlagHamincha(Date startOfDay, Date endOfDay) { * The day is calculated from {@link #getSeaLevelSunrise() sea level sunrise} to {@link #getSeaLevelSunrise sea level * sunset} or {@link #getSunrise() sunrise} to {@link #getSunset() sunset} (depending on the {@link #isUseElevation()} * - * @see #getPlagHamincha(Date, Date) + * @see #getPlagHamincha(Long, Long) * @see ComplexZmanimCalendar#getPlagHaminchaBaalHatanya() * @return the Date of the time of plag hamincha. If the calculation can't be computed such as * in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it * does not set, a null will be returned. See detailed explanation on top of the * {@link AstronomicalCalendar} documentation. */ - public Date getPlagHamincha() { + public Long getPlagHamincha() { return getPlagHamincha(getElevationAdjustedSunrise(), getElevationAdjustedSunset()); } /** - * A method that returns a shaah zmanis ({@link #getTemporalHour(Date, Date) temporal hour}) according to + * A method that returns a shaah zmanis ({@link #getTemporalHour(Long, Long) temporal hour}) according to * the opinion of the GRA. This calculation divides * the day based on the opinion of the GRA that the day runs from from {@link #getSeaLevelSunrise() sea * level sunrise} to {@link #getSeaLevelSunrise sea level sunset} or {@link #getSunrise() sunrise} to @@ -625,7 +624,7 @@ public Date getPlagHamincha() { * If the calculation can't be computed such as in the Arctic Circle where there is at least one day a year * where the sun does not rise, and one where it does not set, {@link Long#MIN_VALUE} will be returned. See * detailed explanation on top of the {@link AstronomicalCalendar} documentation. - * @see #getTemporalHour(Date, Date) + * @see #getTemporalHour(Long, Long) * @see #getSeaLevelSunrise() * @see #getSeaLevelSunset() * @see ComplexZmanimCalendar#getShaahZmanisBaalHatanya() @@ -717,7 +716,7 @@ public void setCandleLightingOffset(double candleLightingOffset) { * @see JewishCalendar#hasCandleLighting() * @see JewishCalendar#setInIsrael(boolean) */ - public boolean isAssurBemlacha(Date currentTime, Date tzais, boolean inIsrael) { + public boolean isAssurBemlacha(Long currentTime, Long tzais, boolean inIsrael) { JewishCalendar jewishCalendar = new JewishCalendar(); jewishCalendar.setGregorianDate(getCalendar().get(Calendar.YEAR), getCalendar().get(Calendar.MONTH), getCalendar().get(Calendar.DAY_OF_MONTH)); @@ -737,7 +736,7 @@ public boolean isAssurBemlacha(Date currentTime, Date tzais, boolean inIsrael) { /** * A generic utility method for calculating any shaah zmanis (temporal hour) based zman with the * day defined as the start and end of day (or night) and the number of shaahos zmaniyos passed to the - * method. This simplifies the code in other methods such as {@link #getPlagHamincha(Date, Date)} and cuts down on + * method. This simplifies the code in other methods such as {@link #getPlagHamincha(Long, Long)} and cuts down on * code replication. As an example, passing {@link #getSunrise() sunrise} and {@link #getSunset sunset} or {@link * #getSeaLevelSunrise() sea level sunrise} and {@link #getSeaLevelSunset() sea level sunset} (depending on the * {@link #isUseElevation()} elevation setting) and 10.75 hours to this method will return plag mincha @@ -757,7 +756,7 @@ public boolean isAssurBemlacha(Date currentTime, Date tzais, boolean inIsrael) { * where it does not set, a null will be returned. See detailed explanation on top of the {@link * AstronomicalCalendar} documentation. */ - public Date getShaahZmanisBasedZman(Date startOfDay, Date endOfDay, double hours) { + public Long getShaahZmanisBasedZman(Long startOfDay, Long endOfDay, double hours) { long shaahZmanis = getTemporalHour(startOfDay, endOfDay); return getTimeOffset(startOfDay, shaahZmanis * hours); } diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java index 9a2652f0..29af122c 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java @@ -946,7 +946,7 @@ public int getDayOfOmer() { * * @return the Date representing the moment of the molad in Yerushalayim standard time (GMT + 2) */ - public Date getMoladAsDate() { + public Long getMoladAsDate() { JewishDate molad = getMolad(); String locationName = "Jerusalem, Israel"; @@ -966,7 +966,7 @@ public Date getMoladAsDate() { cal.set(Calendar.MILLISECOND, (int) (1000 * (moladSeconds - (int) moladSeconds))); // subtract local time difference of 20.94 minutes (20 minutes and 56.496 seconds) to get to Standard time cal.add(Calendar.MILLISECOND, -1 * (int) geo.getLocalMeanTimeOffset()); - return cal.getTime(); + return cal.getTimeInMillis(); } /** @@ -979,12 +979,12 @@ public Date getMoladAsDate() { * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana3Days() * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana3Days(Date, Date) */ - public Date getTchilasZmanKidushLevana3Days() { - Date molad = getMoladAsDate(); + public Long getTchilasZmanKidushLevana3Days() { + Long molad = getMoladAsDate(); Calendar cal = Calendar.getInstance(); - cal.setTime(molad); + cal.setTimeInMillis(molad); cal.add(Calendar.HOUR, 72); // 3 days after the molad - return cal.getTime(); + return cal.getTimeInMillis(); } /** @@ -999,12 +999,12 @@ public Date getTchilasZmanKidushLevana3Days() { * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana7Days() * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getTchilasZmanKidushLevana7Days(Date, Date) */ - public Date getTchilasZmanKidushLevana7Days() { - Date molad = getMoladAsDate(); + public Long getTchilasZmanKidushLevana7Days() { + Long molad = getMoladAsDate(); Calendar cal = Calendar.getInstance(); - cal.setTime(molad); + cal.setTimeInMillis(molad); cal.add(Calendar.HOUR, 168); // 7 days after the molad - return cal.getTime(); + return cal.getTimeInMillis(); } /** @@ -1021,10 +1021,10 @@ public Date getTchilasZmanKidushLevana7Days() { * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevanaBetweenMoldos() * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevanaBetweenMoldos(Date, Date) */ - public Date getSofZmanKidushLevanaBetweenMoldos() { - Date molad = getMoladAsDate(); + public Long getSofZmanKidushLevanaBetweenMoldos() { + Long molad = getMoladAsDate(); Calendar cal = Calendar.getInstance(); - cal.setTime(molad); + cal.setTimeInMillis(molad); // add half the time between molad and molad (half of 29 days, 12 hours and 793 chalakim (44 minutes, 3.3 // seconds), or 14 days, 18 hours, 22 minutes and 666 milliseconds). Add it as hours, not days, to avoid // DST/ST crossover issues. @@ -1032,7 +1032,7 @@ public Date getSofZmanKidushLevanaBetweenMoldos() { cal.add(Calendar.MINUTE, 22); cal.add(Calendar.SECOND, 1); cal.add(Calendar.MILLISECOND, 666); - return cal.getTime(); + return cal.getTimeInMillis(); } /** @@ -1052,12 +1052,12 @@ public Date getSofZmanKidushLevanaBetweenMoldos() { * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevana15Days() * @see com.kosherjava.zmanim.ComplexZmanimCalendar#getSofZmanKidushLevana15Days(Date, Date) */ - public Date getSofZmanKidushLevana15Days() { - Date molad = getMoladAsDate(); + public Long getSofZmanKidushLevana15Days() { + Long molad = getMoladAsDate(); Calendar cal = Calendar.getInstance(); - cal.setTime(molad); + cal.setTimeInMillis(molad); cal.add(Calendar.HOUR, 24 * 15); //15 days after the molad. Add it as hours, not days, to avoid DST/ST crossover issues. - return cal.getTime(); + return cal.getTimeInMillis(); } /** From b928d224da8b49f6b705d6d85b5901a649a49c38 Mon Sep 17 00:00:00 2001 From: Moshe Waisberg Date: Tue, 21 Jun 2022 10:03:14 +0300 Subject: [PATCH 3/3] Java Date was deprecated ages ago --- .../kosherjava/zmanim/ComplexZmanimCalendar.java | 2 +- .../kosherjava/zmanim/util/ZmanimFormatter.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java index d7745f9c..7eff12a0 100644 --- a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java @@ -2843,7 +2843,7 @@ public Long getTzais72Zmanis() { */ private Long getZmanisBasedOffset(double hours) { long shaahZmanis = getShaahZmanisGra(); - if (shaahZmanis == Long.MIN_VALUE || hours == 0) { + if (shaahZmanis == NEVER || hours == 0) { return null; } diff --git a/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java b/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java index 5718ba21..8e8ff631 100644 --- a/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java @@ -15,6 +15,8 @@ */ package com.kosherjava.zmanim.util; +import static com.kosherjava.zmanim.AstronomicalCalendar.NEVER; + import java.lang.reflect.Method; import java.text.DateFormat; import java.text.DecimalFormat; @@ -471,13 +473,13 @@ public static String toXML(AstronomicalCalendar astronomicalCalendar) { // otherList.add("<" + tagName + " xs:nil=\"true\" />"); } else if (value instanceof Date) { dateList.add(new Zman((Date) value, tagName)); - } else if (value instanceof Long || value instanceof Integer) {// shaah zmanis - if (((Long) value).longValue() == Long.MIN_VALUE) { + } else if (value instanceof Number) {// shaah zmanis + if (((Number) value).longValue() == NEVER) { otherList.add("<" + tagName + ">N/A"); // TODO: instead of N/A, consider return proper xs:nil. // otherList.add("<" + tagName + " xs:nil=\"true\" />"); } else { - durationList.add(new Zman((int) ((Long) value).longValue(), tagName)); + durationList.add(new Zman(((Number) value).longValue(), tagName)); } } else { // will probably never enter this block, but is present to be future proof otherList.add("<" + tagName + ">" + value + ""); @@ -621,11 +623,11 @@ public static String toJSON(AstronomicalCalendar astronomicalCalendar) { otherList.add("\"" + tagName + "\":\"N/A\","); } else if (value instanceof Date) { dateList.add(new Zman((Date) value, tagName)); - } else if (value instanceof Long || value instanceof Integer) {// shaah zmanis - if (((Long) value).longValue() == Long.MIN_VALUE) { + } else if (value instanceof Number) {// shaah zmanis + if (((Number) value).longValue() == NEVER) { otherList.add("\"" + tagName + "\":\"N/A\""); } else { - durationList.add(new Zman((int) ((Long) value).longValue(), tagName)); + durationList.add(new Zman(((Number) value).longValue(), tagName)); } } else { // will probably never enter this block, but is present to be future proof otherList.add("\"" + tagName + "\":\"" + value + "\",");