Class LunarTime
- All Implemented Interfaces:
Serializable
,GeoLocation
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
Modifier and TypeClassDescriptionstatic class
Helper class to construct a new instance ofLunarTime
.static class
Collects all moon presence data for a given calendar date and zone of observer. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
hashCode()
static LunarTime.Builder
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.toString()
-
Method Details
-
ofLocation
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
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 positionlatitude
- 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 positionlatitude
- 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 interfaceGeoLocation
- 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 interfaceGeoLocation
- 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 interfaceGeoLocation
- Returns:
- altitude in meters (
0 <= x < 11,0000
)
-
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
-
hashCode
public int hashCode() -
toString
-
on
Determines moonrise and moonset on given calendar date.
- Parameters:
date
- calendar date- Returns:
- data with moonrise and moonset
-