Class LunarTime

java.lang.Object
net.time4j.calendar.astro.LunarTime
All Implemented Interfaces:
Serializable, GeoLocation

public final class LunarTime extends Object implements GeoLocation, Serializable

Contains various routines to determine times of some moon events like moonrise or moonset.

Moonrise and moonset are not tightly coupled to the day cycle which follows the sun. Therefore it is sometimes possible to have only one or none of both events happening at a given calendar date. Furthermore, the moon can also first sets and then rises on the same day. Example of usage:

     Timezone tz = Timezone.of("Europe/Berlin");
     LunarTime munich = LunarTime.ofLocation(tz.getID(), 48.1, 11.6);
     LunarTime.Moonlight moonlight = munich.on(PlainDate.of(2000, 3, 25));
     assertThat(
       moonlight.moonrise().isPresent(),
       is(false));
     assertThat(
       moonlight.moonset().get(),
       is(PlainTimestamp.of(2000, 3, 25, 8, 58, 33).in(tz)));
 
Since:
3.38/4.33
Author:
Meno Hochschild
See Also:
Serialized Form
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Helper class to construct a new instance of LunarTime.
    static class 
    Collects all moon presence data for a given calendar date and zone of observer.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals​(Object obj)
     
    int
    Obtains the geographical altitude of this instance relative to sea level.
    double
    Obtains the geographical latitude of this instance.
    double
    Obtains the geographical longitude of this instance.
    Obtains the observer timezone which is associated with any calendar date input.
    int
     
    ofLocation​(TZID observerZoneID)
    Obtains a builder for creating a new instance of local lunar time.
    static LunarTime
    ofLocation​(TZID observerZoneID, double latitude, double longitude)
    Obtains the lunar time for given geographical location.
    static LunarTime
    ofLocation​(TZID observerZoneID, double latitude, double longitude, int altitude)
    Obtains the lunar time for given geographical location.
    on​(CalendarDate date)
    Determines moonrise and moonset on given calendar date.
     

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • ofLocation

      public static LunarTime.Builder ofLocation(TZID observerZoneID)

      Obtains a builder for creating a new instance of local lunar time.

      This method is the recommended approach if any given geographical position is described in degrees including arc minutes and arc seconds in order to avoid manual conversions to decimal degrees.

      Parameters:
      observerZoneID - timezone identifier associated with geographical position
      Returns:
      builder for creating a new instance of local lunar time
    • ofLocation

      public static LunarTime ofLocation(TZID observerZoneID, double latitude, double longitude)

      Obtains the lunar time for given geographical location.

      This method handles the geographical location in decimal degrees only. If these data are given in degrees, arc minutes and arc seconds then users should apply the builder approach instead.

      Parameters:
      observerZoneID - timezone identifier associated with geographical position
      latitude - geographical latitude in decimal degrees (-90.0 <= x <= +90.0)
      longitude - geographical longitude in decimal degrees (-180.0 <= x < 180.0)
      Returns:
      instance of local lunar time
      Throws:
      IllegalArgumentException - if the coordinates are out of range or the timezone cannot be loaded
    • ofLocation

      public static LunarTime ofLocation(TZID observerZoneID, double latitude, double longitude, int altitude)

      Obtains the lunar time for given geographical location.

      This method handles the geographical location in decimal degrees only. If these data are given in degrees, arc minutes and arc seconds then users should apply the builder approach instead.

      Parameters:
      observerZoneID - timezone identifier associated with geographical position
      latitude - geographical latitude in decimal degrees (-90.0 <= x <= +90.0)
      longitude - geographical longitude in decimal degrees (-180.0 <= x < 180.0)
      altitude - geographical altitude relative to sea level in meters (0 <= x < 11,0000)
      Returns:
      instance of local lunar time
      Throws:
      IllegalArgumentException - if the coordinates are out of range or the timezone cannot be loaded
    • getLatitude

      public double getLatitude()
      Description copied from interface: GeoLocation

      Obtains the geographical latitude of this instance.

      Specified by:
      getLatitude in interface GeoLocation
      Returns:
      latitude in decimal degrees (-90.0 <= x <= +90.0)
    • getLongitude

      public double getLongitude()
      Description copied from interface: GeoLocation

      Obtains the geographical longitude of this instance.

      Specified by:
      getLongitude in interface GeoLocation
      Returns:
      longitude in decimal degrees (-180.0 <= x < 180.0)
    • getAltitude

      public int getAltitude()
      Description copied from interface: GeoLocation

      Obtains the geographical altitude of this instance relative to sea level.

      Specified by:
      getAltitude in interface GeoLocation
      Returns:
      altitude in meters (0 <= x < 11,0000)
    • getObserverZoneID

      public TZID getObserverZoneID()

      Obtains the observer timezone which is associated with any calendar date input.

      Returns:
      zone identifier associated with this geographical position
      Since:
      5.6
      See Also:
      ofLocation(TZID)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • on

      public LunarTime.Moonlight on(CalendarDate date)

      Determines moonrise and moonset on given calendar date.

      Parameters:
      date - calendar date
      Returns:
      data with moonrise and moonset