| /* |
| /* |
| * Zmanim Java API |
| * Zmanim Java API |
| * Copyright (C) 2004-2009 Eliyahu Hershfeld |
| * Copyright (C) 2004-2009 Eliyahu Hershfeld |
| * |
| * |
| * This program is free software; you can redistribute it and/or modify it under the terms of the |
| * This program is free software; you can redistribute it and/or modify it under the terms of the |
| * GNU General Public License as published by the Free Software Foundation; either version 2 of the |
| * GNU General Public License as published by the Free Software Foundation; either version 2 of the |
| * License, or (at your option) any later version. |
| * License, or (at your option) any later version. |
| * |
| * |
| * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without |
| * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without |
| * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| * General Public License for more details. |
| * General Public License for more details. |
| * |
| * |
| * You should have received a copy of the GNU General Public License along with this program; if |
| * You should have received a copy of the GNU General Public License along with this program; if |
| * not, write to the Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA |
| * not, write to the Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA |
| * 02111-1307, USA or connect to: http://www.fsf.org/copyleft/gpl.html |
| * 02111-1307, USA or connect to: http://www.fsf.org/copyleft/gpl.html |
| */ |
| */ |
| package net.sourceforge.zmanim; |
| package net.sourceforge.zmanim; |
| |
| |
| import java.util.Calendar; |
| import java.util.Calendar; |
| import java.util.Date; |
| import java.util.Date; |
| |
| |
| import net.sourceforge.zmanim.util.AstronomicalCalculator; |
| import net.sourceforge.zmanim.util.AstronomicalCalculator; |
| import net.sourceforge.zmanim.util.GeoLocation; |
| import net.sourceforge.zmanim.util.GeoLocation; |
| |
| |
| /** |
| /** |
| * <p> |
| * <p> |
| * Description: A Java library for calculating zmanim. |
| * Description: A Java library for calculating zmanim. |
| * </p> |
| * </p> |
| * The zmanim library is an API is a specialized calendar that can calculate |
| * The zmanim library is an API is a specialized calendar that can calculate |
| * sunrise and sunset and Jewish <em>zmanim</em> (religious times) for prayers |
| * sunrise and sunset and Jewish <em>zmanim</em> (religious times) for prayers |
| * and other Jewish religious duties. For a much more extensive list of zmanim |
| * and other Jewish religious duties. For a much more extensive list of zmanim |
| * use the {@link ComplexZmanimCalendar} that extends this class. This class |
| * use the {@link ComplexZmanimCalendar} that extends this class. This class |
| * contains the main functionality of the Zmanim library. See documentation for |
| * contains the main functionality of the Zmanim library. See documentation for |
| * the {@link ComplexZmanimCalendar} and {@link AstronomicalCalendar} for simple |
| * the {@link ComplexZmanimCalendar} and {@link AstronomicalCalendar} for simple |
| * examples on using the API. |
| * examples on using the API. |
| * <h2>Disclaimer:</h2> |
| * <h2>Disclaimer:</h2> |
| * While I did my best to get accurate results please do not rely on these |
| * While I did my best to get accurate results please do not rely on these |
| * zmanim for <em>halacha lemaaseh</em> |
| * zmanim for <em>halacha lemaaseh</em> |
| * |
| * |
| * @author © Eliyahu Hershfeld 2004 - 2009 |
| * @author © Eliyahu Hershfeld 2004 - 2009 |
| * @version 1.1 |
| * @version 1.1 |
| */ |
| */ |
| public class ZmanimCalendar extends AstronomicalCalendar { |
| public class ZmanimCalendar extends AstronomicalCalendar { |
| private static final long serialVersionUID = 1; |
| private static final long serialVersionUID = 1; |
| |
| |
| /** |
| /** |
| * The zenith of 16.1° below geometric zenith (90°). This |
| * The zenith of 16.1° below geometric zenith (90°). This |
| * calculation is used for calculating <em>alos</em> (dawn) and |
| * calculation is used for calculating <em>alos</em> (dawn) and |
| * <em>tzais</em> (nightfall) in some opinions. This calculation is based |
| * <em>tzais</em> (nightfall) in some opinions. This calculation is based |
| * on the calculation that the time between dawn and sunrise (and sunset to |
| * on the calculation that the time between dawn and sunrise (and sunset to |
| * nightfall) is the time that is takes to walk 4 <em>mil</em> at 18 |
| * nightfall) is the time that is takes to walk 4 <em>mil</em> at 18 |
| * minutes a mil (<em>Ramba"m</em> and others). The sun's position at 72 |
| * minutes a mil (<em>Ramba"m</em> and others). The sun's position at 72 |
| * minutes before {@link #getSunrise sunrise} in Jerusalem on the equinox is |
| * minutes before {@link #getSunrise sunrise} in Jerusalem on the equinox is |
| * 16.1° below {@link #GEOMETRIC_ZENITH geometric zenith}. |
| * 16.1° below {@link #GEOMETRIC_ZENITH geometric zenith}. |
| * |
| * |
| * @see #getAlosHashachar() |
| * @see #getAlosHashachar() |
| * @see ComplexZmanimCalendar#getAlos16Point1Degrees() |
| * @see ComplexZmanimCalendar#getAlos16Point1Degrees() |
| * @see ComplexZmanimCalendar#getTzais16Point1Degrees() |
| * @see ComplexZmanimCalendar#getTzais16Point1Degrees() |
| * @see ComplexZmanimCalendar#getSofZmanShmaMGA16Point1Degrees() |
| * @see ComplexZmanimCalendar#getSofZmanShmaMGA16Point1Degrees() |
| * @see ComplexZmanimCalendar#getSofZmanTfilaMGA16Point1Degrees() |
| * @see ComplexZmanimCalendar#getSofZmanTfilaMGA16Point1Degrees() |
| * @see ComplexZmanimCalendar#getMinchaGedola16Point1Degrees() |
| * @see ComplexZmanimCalendar#getMinchaGedola16Point1Degrees() |
| * @see ComplexZmanimCalendar#getMinchaKetana16Point1Degrees() |
| * @see ComplexZmanimCalendar#getMinchaKetana16Point1Degrees() |
| * @see ComplexZmanimCalendar#getPlagHamincha16Point1Degrees() |
| * @see ComplexZmanimCalendar#getPlagHamincha16Point1Degrees() |
| * @see ComplexZmanimCalendar#getPlagAlos16Point1ToTzaisGeonim7Point083Degrees() |
| * @see ComplexZmanimCalendar#getPlagAlos16Point1ToTzaisGeonim7Point083Degrees() |
| * @see ComplexZmanimCalendar#getSofZmanShmaAlos16Point1ToSunset() |
| * @see ComplexZmanimCalendar#getSofZmanShmaAlos16Point1ToSunset() |
| */ |
| */ |
| protected static final double ZENITH_16_POINT_1 = GEOMETRIC_ZENITH + 16.1; |
| protected static final double ZENITH_16_POINT_1 = GEOMETRIC_ZENITH + 16.1; |
| |
| |
| /** |
| /** |
| * The zenith of 8.5° below geometric zenith (90°). This calculation |
| * The zenith of 8.5° below geometric zenith (90°). This calculation |
| * is used for calculating <em>alos</em> (dawn) and <em>tzais</em> |
| * is used for calculating <em>alos</em> (dawn) and <em>tzais</em> |
| * (nightfall) in some opinions. This calculation is based on the position |
| * (nightfall) in some opinions. This calculation is based on the position |
| * of the sun 36 minutes after {@link #getSunset sunset} in Jerusalem on |
| * of the sun 36 minutes after {@link #getSunset sunset} in Jerusalem on |
| * March 16, about 4 days before the equinox, the day that a solar hour is |
| * March 16, about 4 days before the equinox, the day that a solar hour is |
| * one hour, which is 8.5° below |
| * one hour, which is 8.5° below |
| * {@link #GEOMETRIC_ZENITH geometric zenith}. The Ohr Meir considers this |
| * {@link #GEOMETRIC_ZENITH geometric zenith}. The Ohr Meir considers this |
| * the time that 3 small starts are visible, later than the required 3 |
| * the time that 3 small starts are visible, later than the required 3 |
| * medium stars. |
| * medium stars. |
| * |
| * |
| * @see #getTzais() |
| * @see #getTzais() |
| * @see ComplexZmanimCalendar#getTzaisGeonim8Point5Degrees() |
| * @see ComplexZmanimCalendar#getTzaisGeonim8Point5Degrees() |
| */ |
| */ |
| protected static final double ZENITH_8_POINT_5 = GEOMETRIC_ZENITH + 8.5; |
| protected static final double ZENITH_8_POINT_5 = GEOMETRIC_ZENITH + 8.5; |
| |
| |
| /** |
| /** |
| * The default Shabbos candle lighting offset is 18 minutes. This can be changed |
| * The default Shabbos candle lighting offset is 18 minutes. This can be changed |
| * via the {@link #setCandleLightingOffset(double)} and retrieved by the |
| * via the {@link #setCandleLightingOffset(double)} and retrieved by the |
| * {@link #getCandleLightingOffset()}. |
| * {@link #getCandleLightingOffset()}. |
| */ |
| */ |
| private double candleLightingOffset = 18; |
| private double candleLightingOffset = 18; |
| |
| |
| /** |
| /** |
| * Returns <em>tzais</em> (nightfall) when the sun is 8.5° below the |
| * Returns <em>tzais</em> (nightfall) when the sun is 8.5° below the |
| * western geometric horizon (90°) after {@link #getSunset sunset}. For |
| * western geometric horizon (90°) after {@link #getSunset sunset}. For |
| * information on the source of this calculation see |
| * information on the source of this calculation see |
| * {@link #ZENITH_8_POINT_5}. |
| * {@link #ZENITH_8_POINT_5}. |
| * |
| * |
| * @return The <code>Date</code> of nightfall. |
| * @return The <code>Date</code> of nightfall. |
| * @see #ZENITH_8_POINT_5 |
| * @see #ZENITH_8_POINT_5 |
| */ |
| */ |
| public Date getTzais() { |
| public Date getTzais() { |
| return this.getSunsetOffsetByDegrees(ZENITH_8_POINT_5); |
| return this.getSunsetOffsetByDegrees(ZENITH_8_POINT_5); |
| } |
| } |
| |
| |
| /** |
| /** |
| * Returns <em>alos</em> (dawn) based on the time when the sun is |
| * Returns <em>alos</em> (dawn) based on the time when the sun is |
| * 16.1° below the eastern {@link #GEOMETRIC_ZENITH geometric horizon} |
| * 16.1° below the eastern {@link #GEOMETRIC_ZENITH geometric horizon} |
| * before {@link #getSunrise sunrise}. For more information the source of |
| * before {@link #getSunrise sunrise}. For more information the source of |
| * 16.1° see {@link #ZENITH_16_POINT_1}. |
| * 16.1° see {@link #ZENITH_16_POINT_1}. |
| * |
| * |
| * @see net.sourceforge.zmanim.ZmanimCalendar#ZENITH_16_POINT_1 |
| * @see net.sourceforge.zmanim.ZmanimCalendar#ZENITH_16_POINT_1 |
| * @return The <code>Date</code> of dawn. |
| * @return The <code>Date</code> of dawn. |
| */ |
| */ |
| public Date getAlosHashachar() { |
| public Date getAlosHashachar() { |
| return getSunriseOffsetByDegrees(ZENITH_16_POINT_1); |
| return getSunriseOffsetByDegrees(ZENITH_16_POINT_1); |
| } |
| } |
| |
| |
| /** |
| /** |
| * Method to return <em>alos</em> (dawn) calculated using 72 minutes |
| * Method to return <em>alos</em> (dawn) calculated using 72 minutes |
| * before {@link #getSeaLevelSunrise() sea level sunrise} (no adjustment for |
| * before {@link #getSeaLevelSunrise() sea level sunrise} (no adjustment for |
| * elevation) based on the time to walk the distance of 4 <em>Mil</em> at |
| * elevation) based on the time to walk the distance of 4 <em>Mil</em> at |
| * 18 minutes a <em>Mil</em>. This is based on the opinion of most |
| * 18 minutes a <em>Mil</em>. This is based on the opinion of most |
| * <em>Rishonim</em> who stated that the time of the <em>Neshef</em> |
| * <em>Rishonim</em> who stated that the time of the <em>Neshef</em> |
| * (time between dawn and sunrise) does not vary by the time of year or |
| * (time between dawn and sunrise) does not vary by the time of year or |
| * location but purely depends on the time it takes to walk the distance of |
| * location but purely depends on the time it takes to walk the distance of |
| * 4 <em>Mil</em>. |
| * 4 <em>Mil</em>. |
| * |
| * |
| * @return the <code>Date</code> representing the time. |
| * @return the <code>Date</code> representing the time. |
| */ |
| */ |
| public Date getAlos72() { |
| public Date getAlos72() { |
| return getTimeOffset(getSeaLevelSunrise(), -72 * MINUTE_MILLIS); |
| return getTimeOffset(getSeaLevelSunrise(), -72 * MINUTE_MILLIS); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns <em>chatzos</em> (midday) following the opinion of |
| * This method returns <em>chatzos</em> (midday) following the opinion of |
| * the GRA that the day for Jewish halachic times start at |
| * the GRA that the day for Jewish halachic times start at |
| * {@link #getSunrise sunrise} and ends at {@link #getSunset sunset}. The |
| * {@link #getSunrise sunrise} and ends at {@link #getSunset sunset}. The |
| * returned value is identical to {@link #getSunTransit()} |
| * returned value is identical to {@link #getSunTransit()} |
| * |
| * |
| * @see AstronomicalCalendar#getSunTransit() |
| * @see AstronomicalCalendar#getSunTransit() |
| * @return the <code>Date</code> of chatzos. |
| * @return the <code>Date</code> of chatzos. |
| */ |
| */ |
| public Date getChatzos() { |
| public Date getChatzos() { |
| return getSunTransit(); |
| return getSunTransit(); |
| } |
| } |
| |
| |
| /** |
| /** |
| * A method that returns "solar" midnight, or the time when the sun is at |
| * A method that returns "solar" midnight, or the time when the sun is at |
| * it's <a href="http://en.wikipedia.org/wiki/Nadir">nadir</a>. <br/><br/><b>Note:</b> |
| * it's <a href="http://en.wikipedia.org/wiki/Nadir">nadir</a>. <br/><br/><b>Note:</b> |
| * this method is experimental and might be removed (or moved) |
| * this method is experimental and might be removed (or moved) |
| * |
| * |
| * @return the <code>Date</code> of Solar Midnight (chatzos layla). |
| * @return the <code>Date</code> of Solar Midnight (chatzos layla). |
| */ |
| */ |
| public Date getSolarMidnight() { |
| public Date getSolarMidnight() { |
| ZmanimCalendar clonedCal = (ZmanimCalendar) clone(); |
| ZmanimCalendar clonedCal = (ZmanimCalendar) clone(); |
| clonedCal.getCalendar().add(Calendar.DAY_OF_MONTH, 1); |
| clonedCal.getCalendar().add(Calendar.DAY_OF_MONTH, 1); |
| Date sunset = getSunset(); |
| Date sunset = getSunset(); |
| Date sunrise = clonedCal.getSunrise(); |
| Date sunrise = clonedCal.getSunrise(); |
| return getTimeOffset(sunset, getTemporalHour(sunset, sunrise) * 6); |
| return getTimeOffset(sunset, getTemporalHour(sunset, sunrise) * 6); |
| } |
| } |
| |
| |
| // public Date getChatzosLaylaRSZ() { |
| // public Date getChatzosLaylaRSZ() { |
| // ZmanimCalendar clonedCal = (ZmanimCalendar)clone(); |
| // ZmanimCalendar clonedCal = (ZmanimCalendar)clone(); |
| // clonedCal.getCalendar().add(Calendar.DAY_OF_MONTH, 1); |
| // clonedCal.getCalendar().add(Calendar.DAY_OF_MONTH, 1); |
| // Date sunset = getSunset(); |
| // Date sunset = getSunset(); |
| // Date sunrise = clonedCal.getAlosHashachar(); |
| // Date sunrise = clonedCal.getAlosHashachar(); |
| // return getTimeOffset(sunset, getTemporalHour(sunset, sunrise) * 6); |
| // return getTimeOffset(sunset, getTemporalHour(sunset, sunrise) * 6); |
| // } |
| // } |
| |
| |
| /** |
| /** |
| * This method returns the latest <em>zman krias shema</em> (time to say |
| * This method returns the latest <em>zman krias shema</em> (time to say |
| * Shema in the morning). This time is 3 |
| * Shema in the morning). This time is 3 |
| * <em>{@link #getShaahZmanisGra() shaos zmaniyos}</em> (solar hours) |
| * <em>{@link #getShaahZmanisGra() shaos zmaniyos}</em> (solar hours) |
| * after {@link #getSunrise() sunrise} based on the opinion of the |
| * after {@link #getSunrise() sunrise} based on the opinion of the |
| * <em>GR"A</em> and the <em>Baal Hatanya</em> that the day is |
| * <em>GR"A</em> and the <em>Baal Hatanya</em> that the day is |
| * calculated from sunrise to sunset. This returns the time 3 *{@link #getShaahZmanisGra()} |
| * calculated from sunrise to sunset. This returns the time 3 *{@link #getShaahZmanisGra()} |
| * after {@link #getSunrise() sunrise}. |
| * after {@link #getSunrise() sunrise}. |
| * |
| * |
| * @see net.sourceforge.zmanim.ZmanimCalendar#getShaahZmanisGra() |
| * @see net.sourceforge.zmanim.ZmanimCalendar#getShaahZmanisGra() |
| * @return the <code>Date</code> of the latest zman shema. |
| * @return the <code>Date</code> of the latest zman shema. |
| */ |
| */ |
| public Date getSofZmanShmaGRA() { |
| public Date getSofZmanShmaGRA() { |
| return getTimeOffset(getSunrise(), getShaahZmanisGra() * 3); |
| return getTimeOffset(getSeaLevelSunrise(), getShaahZmanisGra() * 3); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns the latest <em>zman krias shema</em> (time to say |
| * This method returns the latest <em>zman krias shema</em> (time to say |
| * Shema in the morning) in the opinion of the <em>MG"A</em> based on |
| * Shema in the morning) in the opinion of the <em>MG"A</em> based on |
| * <em>alos</em> being 72 minutes before {@link #getSunrise() sunrise}. |
| * <em>alos</em> being 72 minutes before {@link #getSunrise() sunrise}. |
| * This time is 3 <em> shaos zmaniyos</em> (solar hours) after dawn based |
| * This time is 3 <em> shaos zmaniyos</em> (solar hours) after dawn based |
| * on the opinion of the <em>MG"A</em> that the day is calculated from a |
| * on the opinion of the <em>MG"A</em> that the day is calculated from a |
| * dawn of 72 minutes before sunrise to nightfall of 72 minutes after |
| * dawn of 72 minutes before sunrise to nightfall of 72 minutes after |
| * sunset. This returns the time of 3 * <em>shaos zmaniyos</em> after |
| * sunset. This returns the time of 3 * <em>shaos zmaniyos</em> after |
| * dawn. |
| * dawn. |
| * |
| * |
| * @return the <code>Date</code> of the latest zman shema. |
| * @return the <code>Date</code> of the latest zman shema. |
| * @see ComplexZmanimCalendar#getShaahZmanis72Minutes() |
| * @see ComplexZmanimCalendar#getShaahZmanis72Minutes() |
| * @see ComplexZmanimCalendar#getAlos72() |
| * @see ComplexZmanimCalendar#getAlos72() |
| * @see ComplexZmanimCalendar#getSofZmanShmaMGA72Minutes() |
| * @see ComplexZmanimCalendar#getSofZmanShmaMGA72Minutes() |
| */ |
| */ |
| public Date getSofZmanShmaMGA() { |
| public Date getSofZmanShmaMGA() { |
| return getTimeOffset(getAlos72(), getShaahZmanisMGA() * 3); |
| return getTimeOffset(getAlos72(), getShaahZmanisMGA() * 3); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns the <em>tzais</em> (nightfall) based on the opinion |
| * This method returns the <em>tzais</em> (nightfall) based on the opinion |
| * of the <em>Ramba"m</em> and <em>Rabainu Tam</em> that <em>tzais</em> |
| * of the <em>Ramba"m</em> and <em>Rabainu Tam</em> that <em>tzais</em> |
| * is calculated as the time it takes to walk 4 <em>Mil</em> at 18 minutes |
| * is calculated as the time it takes to walk 4 <em>Mil</em> at 18 minutes |
| * a <em>Mil</em> for a total of 72 minutes. Even for locations above sea |
| * a <em>Mil</em> for a total of 72 minutes. Even for locations above sea |
| * level, this is calculated at sea level, since the darkness level is not |
| * level, this is calculated at sea level, since the darkness level is not |
| * affected by elevation. |
| * affected by elevation. |
| * |
| * |
| * @return the <code>Date</code> representing 72 minutes after sea level |
| * @return the <code>Date</code> representing 72 minutes after sea level |
| * sunset. |
| * sunset. |
| */ |
| */ |
| public Date getTzais72() { |
| public Date getTzais72() { |
| return getTimeOffset(getSeaLevelSunset(), 72 * MINUTE_MILLIS); |
| return getTimeOffset(getSeaLevelSunset(), 72 * MINUTE_MILLIS); |
| } |
| } |
| |
| |
| /** |
| /** |
| * A method to return candle lighting time. This is calculated as |
| * A method to return candle lighting time. This is calculated as |
| * {@link #getCandleLightingOffset()} minutes before sunset. This will |
| * {@link #getCandleLightingOffset()} minutes before sunset. This will |
| * return the time for any day of the week, since it can be used to |
| * return the time for any day of the week, since it can be used to |
| * calculate candle lighting time for <em>yom tov</em> (holidays) as well. |
| * calculate candle lighting time for <em>yom tov</em> (holidays) as well. |
| * |
| * |
| * @return candle lighting time. |
| * @return candle lighting time. |
| * @see #getCandleLightingOffset() |
| * @see #getCandleLightingOffset() |
| * @see #setCandleLightingOffset(double) |
| * @see #setCandleLightingOffset(double) |
| */ |
| */ |
| public Date getCandelLighting() { |
| public Date getCandelLighting() { |
| return getTimeOffset(getSunset(), -getCandleLightingOffset() |
| return getTimeOffset(getSunset(), -getCandleLightingOffset() |
| * MINUTE_MILLIS); |
| * MINUTE_MILLIS); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns the latest |
| * This method returns the latest |
| * <em>zman tefilah<em> (time to pray morning prayers). This time is 4 |
| * <em>zman tefilah<em> (time to pray morning prayers). This time is 4 |
| * hours into the day based on the opinion of the <em>GR"A</em> and the </em>Baal Hatanya</em> |
| * hours into the day based on the opinion of the <em>GR"A</em> and the </em>Baal Hatanya</em> |
| * that the day is calculated from sunrise to sunset. This returns the time |
| * that the day is calculated from sunrise to sunset. This returns the time |
| * 4 * {@link #getShaahZmanisGra()} after {@link #getSunrise() sunrise}. |
| * 4 * {@link #getShaahZmanisGra()} after {@link #getSunrise() sunrise}. |
| * |
| * |
| * @see net.sourceforge.zmanim.ZmanimCalendar#getShaahZmanisGra() |
| * @see net.sourceforge.zmanim.ZmanimCalendar#getShaahZmanisGra() |
| * @return the <code>Date</code> of the latest zman tefilah. |
| * @return the <code>Date</code> of the latest zman tefilah. |
| */ |
| */ |
| public Date getSofZmanTfilaGRA() { |
| public Date getSofZmanTfilaGRA() { |
| return getTimeOffset(getSunrise(), getShaahZmanisGra() * 4); |
| return getTimeOffset(getSeaLevelSunrise(), getShaahZmanisGra() * 4); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns the latest <em>zman tfila</em> (time to say the |
| * This method returns the latest <em>zman tfila</em> (time to say the |
| * morning prayers) in the opinion of the <em>MG"A</em> based on |
| * morning prayers) in the opinion of the <em>MG"A</em> based on |
| * <em>alos</em> being {@link #getAlos72() 72} minutes before |
| * <em>alos</em> being {@link #getAlos72() 72} minutes before |
| * {@link #getSunrise() sunrise}. This time is 4 |
| * {@link #getSunrise() sunrise}. This time is 4 |
| * <em>{@link #getShaahZmanisMGA() shaos zmaniyos}</em> (temporal hours) |
| * <em>{@link #getShaahZmanisMGA() shaos zmaniyos}</em> (temporal hours) |
| * after {@link #getAlos72() dawn} based on the opinion of the <em>MG"A</em> |
| * after {@link #getAlos72() dawn} based on the opinion of the <em>MG"A</em> |
| * that the day is calculated from a {@link #getAlos72() dawn} of 72 minutes |
| * that the day is calculated from a {@link #getAlos72() dawn} of 72 minutes |
| * before sunrise to {@link #getTzais72() nightfall} of 72 minutes after |
| * before sunrise to {@link #getTzais72() nightfall} of 72 minutes after |
| * sunset. This returns the time of 4 * {@link #getShaahZmanisMGA()} after |
| * sunset. This returns the time of 4 * {@link #getShaahZmanisMGA()} after |
| * {@link #getAlos72() dawn}. |
| * {@link #getAlos72() dawn}. |
| * |
| * |
| * @return the <code>Date</code> of the latest zman tfila. |
| * @return the <code>Date</code> of the latest zman tfila. |
| * @see #getShaahZmanisMGA() |
| * @see #getShaahZmanisMGA() |
| * @see #getAlos72() |
| * @see #getAlos72() |
| */ |
| */ |
| public Date getSofZmanTfilaMGA() { |
| public Date getSofZmanTfilaMGA() { |
| return getTimeOffset(getAlos72(), getShaahZmanisMGA() * 4); |
| return getTimeOffset(getAlos72(), getShaahZmanisMGA() * 4); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns the time of <em>mincha gedola</em>.<em>Mincha gedola</em> |
| * This method returns the time of <em>mincha gedola</em>.<em>Mincha gedola</em> |
| * is the earliest time one can pray mincha. The Ramba"m is of the opinion |
| * is the earliest time one can pray mincha. The Ramba"m is of the opinion |
| * that it is better to delay <em>mincha</em> until |
| * that it is better to delay <em>mincha</em> until |
| * <em>{@link #getMinchaKetana() mincha ketana}</em> while the <em>Ra"sh, |
| * <em>{@link #getMinchaKetana() mincha ketana}</em> while the <em>Ra"sh, |
| * Tur, GR"A</em> |
| * Tur, GR"A</em> |
| * and others are of the opinion that <em>mincha</em> can be prayed |
| * and others are of the opinion that <em>mincha</em> can be prayed |
| * <em>lechatchila</em> starting at <em>mincha gedola</em>. This is |
| * <em>lechatchila</em> starting at <em>mincha gedola</em>. This is |
| * calculated as 6.5 {@link #getTemporalHour() solar hours} after sunrise. |
| * calculated as 6.5 {@link #getTemporalHour() solar hours} after sunrise. |
| * This calculation is calculated based on the opinion of the <em>GR"A</em> |
| * This calculation is calculated based on the opinion of the <em>GR"A</em> |
| * and the <em>Baal Hatanya</em> that the day is calculated from sunrise |
| * and the <em>Baal Hatanya</em> that the day is calculated from sunrise |
| * to sunset. This returns the time 6.5 *{@link #getShaahZmanisGra()} after |
| * to sunset. This returns the time 6.5 *{@link #getShaahZmanisGra()} after |
| * {@link #getSunrise() sunrise}. |
| * {@link #getSunrise() sunrise}. |
| * |
| * |
| * @see #getShaahZmanisGra() |
| * @see #getShaahZmanisGra() |
| * @see #getMinchaKetana() |
| * @see #getMinchaKetana() |
| * @return the <code>Date</code> of the time of mincha gedola. |
| * @return the <code>Date</code> of the time of mincha gedola. |
| */ |
| */ |
| public Date getMinchaGedola() { |
| public Date getMinchaGedola() { |
| return getTimeOffset(getSunrise(), getShaahZmanisGra() * 6.5); |
| return getTimeOffset(getSeaLevelSunrise(), getShaahZmanisGra() * 6.5); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns the time of <em>mincha ketana</em>. This is the |
| * This method returns the time of <em>mincha ketana</em>. This is the |
| * perfered earliest time to pray <em>mincha</em> in the opinion of the |
| * perfered earliest time to pray <em>mincha</em> in the opinion of the |
| * Ramba"m and others. For more information on this see the documentation on |
| * Ramba"m and others. For more information on this see the documentation on |
| * <em>{@link #getMinchaGedola() mincha gedola}</em>. This is calculated |
| * <em>{@link #getMinchaGedola() mincha gedola}</em>. This is calculated |
| * as 9.5 {@link #getTemporalHour() solar hours}after sunrise. This |
| * as 9.5 {@link #getTemporalHour() solar hours}after sunrise. This |
| * calculation is calculated based on the opinion of the <em>GR"A</em> and |
| * calculation is calculated based on the opinion of the <em>GR"A</em> and |
| * the <em>Baal Hatanya</em> that the day is calculated from sunrise to |
| * the <em>Baal Hatanya</em> that the day is calculated from sunrise to |
| * sunset. This returns the time 9.5 * {@link #getShaahZmanisGra()} after |
| * sunset. This returns the time 9.5 * {@link #getShaahZmanisGra()} after |
| * {@link #getSunrise() sunrise}. |
| * {@link #getSunrise() sunrise}. |
| * |
| * |
| * @see #getShaahZmanisGra() |
| * @see #getShaahZmanisGra() |
| * @see #getMinchaGedola() |
| * @see #getMinchaGedola() |
| * @return the <code>Date</code> of the time of mincha gedola. |
| * @return the <code>Date</code> of the time of mincha gedola. |
| */ |
| */ |
| public Date getMinchaKetana() { |
| public Date getMinchaKetana() { |
| return getTimeOffset(getSunrise(), getShaahZmanisGra() * 9.5); |
| return getTimeOffset(getSeaLevelSunrise(), getShaahZmanisGra() * 9.5); |
| } |
| } |
| |
| |
| /** |
| /** |
| * This method returns he time of <em>plag hamincha</em>. This is |
| * This method returns he time of <em>plag hamincha</em>. This is |
| * calculated as 10.75 hours after sunrise. This calculation is calculated |
| * calculated as 10.75 hours after sunrise. This calculation is calculated |
| * based on the opinion of the <em>GR"A</em> and the <em>Baal Hatanya</em> |
| * based on the opinion of the <em>GR"A</em> and the <em>Baal Hatanya</em> |
| * that the day is calculated from sunrise to sunset. This returns the time |
| * that the day is calculated from sunrise to sunset. This returns the time |
| * 10.75 *{@link #getShaahZmanisGra()} after {@link #getSunrise() sunrise}. |
| * 10.75 *{@link #getShaahZmanisGra()} after {@link #getSunrise() sunrise}. |
| * |
| * |
| * @return the <code>Date</code> of the time of <em>plag hamincha</em>. |
| * @return the <code>Date</code> of the time of <em>plag hamincha</em>. |
| */ |
| */ |
| public Date getPlagHamincha() { |
| public Date getPlagHamincha() { |
| return getTimeOffset(getSunrise(), getShaahZmanisGra() * 10.75); |
| return getTimeOffset(getSeaLevelSunrise(), getShaahZmanisGra() * 10.75); |
| } |
| } |
| |
| |
| /** |
| /** |
| * Method to return a <em>shaah zmanis</em> ({@link #getTemporalHour temporal hour}) |
| * Method to return a <em>shaah zmanis</em> ({@link #getTemporalHour temporal hour}) |
| * according to the opinion of the <em>GR"A</em> and the |
| * according to the opinion of the <em>GR"A</em> and the |
| * <em>Baal Hatanya</em>. This calculation divides the day based on the |
| * <em>Baal Hatanya</em>. This calculation divides the day based on the |
| * opinion of the <em>GR"A</em> and the <em>Baal Hatanya</em> that the |
| * opinion of the <em>GR"A</em> and the <em>Baal Hatanya</em> that the |
| * day runs from {@link #getSunrise() sunrise} to {@link #getSunset sunset}. |
| * day runs from {@link #getSunrise() sunrise} to {@link #getSunset sunset}. |
| * The day is split into 12 equal parts each part with each one being a |
| * The day is split into 12 equal parts each part with each one being a |
| * <em>shaah zmanis</em>. This method is identical to |
| * <em>shaah zmanis</em>. This method is similar to |
| * {@link #getTemporalHour} (it is actually a wrapper that calls that |
| * {@link #getTemporalHour}, but all calculations are based on a sealevel sunrise |
| * method) and is provided for clarity. |
| * and sunset. For additional information, see Zmanim Kehilchasam, 2nd Edition by Rabbi Dovid Yehuda Burstein, Jerusalem, 2007. |
| * |
| * |
| * @return the <code>long</code> millisecond length of a |
| * @return the <code>long</code> millisecond length of a |
| * <em>shaah zmanis</em>. |
| * <em>shaah zmanis</em>. |
| * @see #getTemporalHour() |
| * @see #getTemporalHour() |
| */ |
| */ |
| public long getShaahZmanisGra() { |
| public long getShaahZmanisGra() { |
| return getTemporalHour(); |
| //return getTemporalHour(); |
| |
| return getTemporalHour(getSeaLevelSunrise(), getSeaLevelSunset());
|
| } |
| } |
| |
| |
| /** |
| /** |
| * Method to return a <em>shaah zmanis</em> (temporal hour) according to |
| * Method to return a <em>shaah zmanis</em> (temporal hour) according to |
| * the opinion of the MGA. This calculation divides the day based on the |
| * the opinion of the MGA. This calculation divides the day based on the |
| * opinion of the <em>MGA</em> that the day runs from dawn to dusk (for |
| * opinion of the <em>MGA</em> that the day runs from dawn to dusk (for |
| * sof zman krias shema and tfila). Dawn for this calculation is 72 minutes |
| * sof zman krias shema and tfila). Dawn for this calculation is 72 minutes |
| * before sunrise and dusk is 72 minutes after sunset. This day is split |
| * before sunrise and dusk is 72 minutes after sunset. This day is split |
| * into 12 equal parts with each part being a <em>shaah zmanis</em>. |
| * into 12 equal parts with each part being a <em>shaah zmanis</em>. |
| * Alternate mothods of calculating a <em>shaah zmanis</em> are available |
| * Alternate mothods of calculating a <em>shaah zmanis</em> are available |
| * in the subclass {@link ComplexZmanimCalendar}. |
| * in the subclass {@link ComplexZmanimCalendar}. |
| * |
| * |
| * @return the <code>long</code> millisecond length of a |
| * @return the <code>long</code> millisecond length of a |
| * <em>shaah zmanis</em>. |
| * <em>shaah zmanis</em>. |
| */ |
| */ |
| public long getShaahZmanisMGA() { |
| public long getShaahZmanisMGA() { |
| return getTemporalHour(getAlos72(), getTzais72()); |
| return getTemporalHour(getAlos72(), getTzais72()); |
| } |
| } |
| |
| |
| /** |
| /** |
| * Default constructor will set a default {@link GeoLocation#GeoLocation()}, |
| * Default constructor will set a default {@link GeoLocation#GeoLocation()}, |
| * a default |
| * a default |
| * {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} and |
| * {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} and |
| * default the calendar to the current date. |
| * default the calendar to the current date. |
| * |
| * |
| * @see AstronomicalCalendar#AstronomicalCalendar() |
| * @see AstronomicalCalendar#AstronomicalCalendar() |
| */ |
| */ |
| public ZmanimCalendar() { |
| public ZmanimCalendar() { |
| super(); |
| super(); |
| } |
| } |
| |
| |
| /** |
| /** |
| * A constructor that takes a {@link GeoLocation} as a parameter. |
| * A constructor that takes a {@link GeoLocation} as a parameter. |
| * |
| * |
| * @param location |
| * @param location |
| * the location |
| * the location |
| */ |
| */ |
| public ZmanimCalendar(GeoLocation location) { |
| public ZmanimCalendar(GeoLocation location) { |
| super(location); |
| super(location); |
| } |
| } |
| |
| |
| /** |
| /** |
| * @see java.lang.Object#equals(Object) |
| * @see java.lang.Object#equals(Object) |
| */ |
| */ |
| public boolean equals(Object object) { |
| public boolean equals(Object object) { |
| if (this == object) { |
| if (this == object) { |
| return true; |
| return true; |
| } |
| } |
| if (!(object instanceof ZmanimCalendar)) { |
| if (!(object instanceof ZmanimCalendar)) { |
| return false; |
| return false; |
| } |
| } |
| ZmanimCalendar zCal = (ZmanimCalendar) object; |
| ZmanimCalendar zCal = (ZmanimCalendar) object; |
| // return getCalendar().getTime().equals(zCal.getCalendar().getTime()) |
| // return getCalendar().getTime().equals(zCal.getCalendar().getTime()) |
| return getCalendar().equals(zCal.getCalendar()) |
| return getCalendar().equals(zCal.getCalendar()) |
| && getGeoLocation().equals(zCal.getGeoLocation()) |
| && getGeoLocation().equals(zCal.getGeoLocation()) |
| && getAstronomicalCalculator().equals( |
| && getAstronomicalCalculator().equals( |
| zCal.getAstronomicalCalculator()); |
| zCal.getAstronomicalCalculator()); |
| } |
| } |
| |
| |
| /** |
| /** |
| * @see java.lang.Object#hashCode() |
| * @see java.lang.Object#hashCode() |
| */ |
| */ |
| public int hashCode() { |
| public int hashCode() { |
| int result = 17; |
| int result = 17; |
| result = 37 * result + getClass().hashCode();// needed or this and subclasses will return identical hash |
| result = 37 * result + getClass().hashCode();// needed or this and subclasses will return identical hash |
| result += 37 * result + getCalendar().hashCode(); |
| result += 37 * result + getCalendar().hashCode(); |
| result += 37 * result + getGeoLocation().hashCode(); |
| result += 37 * result + getGeoLocation().hashCode(); |
| result += 37 * result + getAstronomicalCalculator().hashCode(); |
| result += 37 * result + getAstronomicalCalculator().hashCode(); |
| return result; |
| return result; |
| } |
| } |
| |
| |
| /** |
| /** |
| * A method to get the offset in minutes before |
| * A method to get the offset in minutes before |
| * {@link AstronomicalCalendar#getSunset() sunset} that is used in |
| * {@link AstronomicalCalendar#getSunset() sunset} that is used in |
| * calculating candle lighting time. The default time used is 18 minutes |
| * calculating candle lighting time. The default time used is 18 minutes |
| * before sunset. Some calendars use 15 minutes, while the custom in |
| * before sunset. Some calendars use 15 minutes, while the custom in |
| * Jerusalem is to use a 40 minute offset. Please check the local custom for |
| * Jerusalem is to use a 40 minute offset. Please check the local custom for |
| * candel lighting time. |
| * candel lighting time. |
| * |
| * |
| * @return Returns the candle lighting offset to set in minutes.. |
| * @return Returns the candle lighting offset to set in minutes.. |
| * @see #getCandelLighting() |
| * @see #getCandelLighting() |
| */ |
| */ |
| public double getCandleLightingOffset() { |
| public double getCandleLightingOffset() { |
| return candleLightingOffset; |
| return candleLightingOffset; |
| } |
| } |
| |
| |
| /** |
| /** |
| * A method to set the offset in minutes before |
| * A method to set the offset in minutes before |
| * {@link AstronomicalCalendar#getSunset() sunset} that is used in |
| * {@link AstronomicalCalendar#getSunset() sunset} that is used in |
| * calculating candle lighting time. The default time used is 18 minutes |
| * calculating candle lighting time. The default time used is 18 minutes |
| * before sunset. Some calendars use 15 minutes, while the custom in |
| * before sunset. Some calendars use 15 minutes, while the custom in |
| * Jerusalem is to use a 40 minute offset. |
| * Jerusalem is to use a 40 minute offset. |
| * |
| * |
| * @param candleLightingOffset |
| * @param candleLightingOffset |
| * The candle lighting offset to set in minutes. |
| * The candle lighting offset to set in minutes. |
| * @see #getCandelLighting() |
| * @see #getCandelLighting() |
| */ |
| */ |
| public void setCandleLightingOffset(double candleLightingOffset) { |
| public void setCandleLightingOffset(double candleLightingOffset) { |
| this.candleLightingOffset = candleLightingOffset; |
| this.candleLightingOffset = candleLightingOffset; |
| } |
| } |
| } |
| } |
| |
| |