Top Description Inners Fields Constructors Methods
com.ibm.icu.impl

public Class CalendarAstronomer

extends Object
Class Inheritance
Imports
java.util.Date, .TimeZone

CalendarAstronomer is a class that can perform the calculations to determine the positions of the sun and moon, the time of sunrise and sunset, and other astronomy-related data. The calculations it performs are in some cases quite complicated, and this utility class saves you the trouble of worrying about them.

The measurement of time is a very important part of astronomy. Because astronomical bodies are constantly in motion, observations are only valid at a given moment in time. Accordingly, each CalendarAstronomer object has a time property that determines the date and time for which its calculations are performed. You can set and retrieve this property with setDate, getDate and related methods.

Almost all of the calculations performed by this class, or by any astronomer, are approximations to various degrees of accuracy. The calculations in this class are mostly modelled after those described in the book Practical Astronomy With Your Calculator, by Peter J. Duffett-Smith, Cambridge University Press, 1990. This is an excellent book, and if you want a greater understanding of how these calculations are performed it a very good, readable starting point.

Warning

This class is very early in its development, and it is highly likely that its API will change to some degree in the future. At the moment, it basically does just enough to support com.ibm.icu.util.IslamicCalendar and com.ibm.icu.util.ChineseCalendar.

Authors
Laura Werner, Alan Liu
ICU Status
Internal ICU component.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
private static interface
public static class
CalendarAstronomer.Ecliptic

Represents the position of an object in the sky relative to the ecliptic, the plane of the earth's orbit around the Sun.

public static class
CalendarAstronomer.Equatorial

Represents the position of an object in the sky relative to the plane of the earth's equator.

public static class
CalendarAstronomer.Horizon

Represents the position of an object in the sky relative to the local horizon.

private static class
private static class

Field Summary

Modifier and TypeField and Description
public static final CalendarAstronomer.SolarLongitude
AUTUMN_EQUINOX

Constant representing the autumnal equinox.

public static final long
DAY_MS

The number of milliseconds in one day.

private static final double
private transient double
pack-priv static final long
EPOCH_2000_MS

Milliseconds value for 0.0 January 2000 AD.

private long
public static final CalendarAstronomer.MoonAge
FIRST_QUARTER

Constant representing the moon's first quarter.

private double
private double
public static final CalendarAstronomer.MoonAge
FULL_MOON

Constant representing a full moon.

public static final int
HOUR_MS

The number of milliseconds in one hour.

private static final double
pack-priv static final double
public static final long
JULIAN_EPOCH_MS

The start of the julian day numbering scheme used by astronomers, which is 1/1/4713 BC (Julian), 12:00 GMT.

private transient double
private transient double
public static final CalendarAstronomer.MoonAge
LAST_QUARTER

Constant representing the moon's last quarter.

private transient double
public static final int
MINUTE_MS

The number of milliseconds in one minute.

pack-priv static final double
pack-priv static final double
private transient double
pack-priv static final double
pack-priv static final double
private transient double
pack-priv static final double
pack-priv static final double
pack-priv static final double
private transient CalendarAstronomer.Equatorial
pack-priv static final double
public static final CalendarAstronomer.MoonAge
NEW_MOON

Constant representing a new moon.

private static final double
private static final double
private static final double
private static final double
public static final int
SECOND_MS

The number of milliseconds in one second.

public static final double
SIDEREAL_DAY

The number of standard hours in one sidereal day.

public static final double
SIDEREAL_MONTH

The average number of days it takes for the moon to return to the same ecliptic longitude relative to the stellar background.

public static final double
SIDEREAL_YEAR

The average number of days it takes for the sun to return to the same position against the fixed stellar background.

private transient double
private transient double
public static final double
SOLAR_DAY

The number of sidereal hours in one mean solar day.

public static final CalendarAstronomer.SolarLongitude
SUMMER_SOLSTICE

Constant representing the summer solstice.

pack-priv static final double
pack-priv static final double
pack-priv static final double
private transient double
public static final double
SYNODIC_MONTH

The average number of solar days from one new moon to the next.

private long
time

Current time in milliseconds since 1/1/1970 AD

public static final double
TROPICAL_YEAR

The average number number of days between successive vernal equinoxes.

public static final CalendarAstronomer.SolarLongitude
VERNAL_EQUINOX

Constant representing the vernal equinox.

public static final CalendarAstronomer.SolarLongitude
WINTER_SOLSTICE

Constant representing the winter solstice.

Constructor Summary

AccessConstructor and Description
public
CalendarAstronomer()

Construct a new CalendarAstronomer object that is initialized to the current date and time.

public
CalendarAstronomer(Date d)

Construct a new CalendarAstronomer object that is initialized to the specified date and time.

public
CalendarAstronomer(long aTime)

Construct a new CalendarAstronomer object that is initialized to the specified time.

public
CalendarAstronomer(double
The desired longitude, in degrees east of the Greenwich meridian.
longitude
,
double
The desired latitude, in degrees. Positive values signify North, negative South.
latitude
)

Construct a new CalendarAstronomer object with the given latitude and longitude.

Method Summary

Modifier and TypeMethod and Description
private void
private double

Returns:

the obliquity of the ecliptic relative to the equator, measured in radians.
eclipticObliquity
()

Return the obliquity of the ecliptic (the angle between the ecliptic and the earth's equator) at the current time.

public final CalendarAstronomer.Equatorial

Returns:

The corresponding point in equatorial coordinates.
eclipticToEquatorial
(CalendarAstronomer.Ecliptic
A point in the sky in ecliptic coordinates.
ecliptic
)

Convert from ecliptic to equatorial coordinates.

public final CalendarAstronomer.Equatorial

Returns:

The corresponding point in equatorial coordinates.
eclipticToEquatorial
(double
The ecliptic longitude
eclipLong
,
double
The ecliptic latitude
eclipLat
)

Convert from ecliptic to equatorial coordinates.

public final CalendarAstronomer.Equatorial

Returns:

The corresponding point in equatorial coordinates.
eclipticToEquatorial
(double
The ecliptic longitude
eclipLong
)

Convert from ecliptic longitude to equatorial coordinates.

public CalendarAstronomer.Horizon
eclipticToHorizon(double eclipLong)

public Date
getDate()

Get the current time of this CalendarAstronomer object, represented as a Date object.

public double
getGreenwichSidereal()

Returns the current Greenwich sidereal time, measured in hours

public double
getJulianCentury()

Return this object's time expressed in julian centuries: the number of centuries after 1/1/1900 AD, 12:00 GMT

public double
getJulianDay()

Get the current time of this CalendarAstronomer object, expressed as a "julian day number", which is the number of elapsed days since 1/1/4713 BC (Julian), 12:00 GMT.

public double
getLocalSidereal()

Returns the current local sidereal time, measured in hours

public double
getMoonAge()

The "age" of the moon at the time specified in this object.

public double
getMoonPhase()

Calculate the phase of the moon at the time set in this object.

public CalendarAstronomer.Equatorial
getMoonPosition()

The position of the moon at the time set on this object, in equatorial coordinates.

public long
getMoonRiseSet(boolean rise)

Returns the time (GMT) of sunrise or sunset on the local date to which this calendar is currently set.

public long
getMoonTime(double
The desired longitude.
desired
,
boolean
true if the next occurrance of the phase is desired, false for the previous occurrance.
next
)

Find the next or previous time at which the Moon's ecliptic longitude will have the desired value.

public long
getMoonTime(CalendarAstronomer.MoonAge
The desired phase of the moon.
desired
,
boolean
true if the next occurrance of the phase is desired, false for the previous occurrance.
next
)

Find the next or previous time at which the moon will be in the desired phase.

private double
public double
getSunLongitude()

The longitude of the sun at the time specified by this object.

pack-priv double[]
getSunLongitude(double julian)

TODO Make this public when the entire class is package-private.

public CalendarAstronomer.Equatorial
getSunPosition()

The position of the sun at this object's current date and time, in equatorial coordinates.

public long
getSunRiseSet(boolean rise)

Returns the time (GMT) of sunrise or sunset on the local date to which this calendar is currently set.

public long
getSunTime(double desired, boolean next)

Find the next time at which the sun's ecliptic longitude will have the desired value.

public long
getSunTime(CalendarAstronomer.SolarLongitude desired, boolean next)

Find the next time at which the sun's ecliptic longitude will have the desired value.

public long
getTime()

Get the current time of this CalendarAstronomer object, represented as the number of milliseconds since 1/1/1970 AD 0:00 GMT (Gregorian).

public String
local(long localMillis)

private long

Returns:

The corresponding Universal Time, in milliseconds since 1 Jan 1970, GMT.
lstToUT
(double
The Local Sidereal Time, in hours since sidereal midnight on this object's current date.
lst
)

Converts local sidereal time to Universal Time.

private static final double
norm2PI(double angle)

Normalize an angle so that it's in the range 0 - 2pi.

private static final double
normalize(double value, double range)

Given 'value', add or subtract 'range' until 0 <= 'value' < range.

private static final double
normPI(double angle)

Normalize an angle into the range -PI - PI

private static String
radToDms(double angle)

private static String
radToHms(double angle)

private long
riseOrSet(CalendarAstronomer.CoordFunc func, boolean rise, double diameter, double refraction, long epsilon)

public void
setDate(Date
the time and date, expressed as a Date object.
date
)

Set the current date and time of this CalendarAstronomer object.

public void
setJulianDay(double
the desired time, expressed as a "julian day number", which is the number of elapsed days since 1/1/4713 BC (Julian), 12:00 GMT. Note that julian day numbers start at noon. To get the jdn for the corresponding midnight, subtract 0.5.
jdn
)

Set the current date and time of this CalendarAstronomer object.

public void
setTime(long
the date and time, expressed as the number of milliseconds since 1/1/1970 0:00 GMT (Gregorian).
aTime
)

Set the current date and time of this CalendarAstronomer object.

private long
timeOfAngle(CalendarAstronomer.AngleFunc func, double desired, double periodDays, long epsilon, boolean next)

private double

Returns:

The true anomaly (longitude) measured in radians
trueAnomaly
(double
The object's longitude calculated as if it were in a regular, circular orbit, measured in radians from the point of perigee.
meanAnomaly
,
double
The eccentricity of the orbit
eccentricity
)

Find the "true anomaly" (longitude) of an object from its mean anomaly and the eccentricity of its orbit.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait