cds.astro
Class Astrotime

java.lang.Object
  extended by cds.astro.Astrotime

public class Astrotime
extends java.lang.Object

The astronomical time may be expressed in (Modified) Julian Days, Julian Years or Besselian years. The conversion to Calendar can use the Calendar.setTimeInMillis(JD2Millis(date))


Field Summary
static double Byr
          Value of Besselian Year in days
static Editing ed
          The default choices of the edition for this class
static double JD_1970
          Julian date of 1 Jan 1970
static double JD_B1900
          Julian date of B1900 epoch
static double JD_J2000
          Julian date of J2000 epoch
static double JD_MJD0
          Modified Julian date
static double Jyr
          Value of the Julian Year in days
protected  double mjd
          The actual date/epoch is stored as MJD value (JD-2400000.5)
static double[] offset
          Origin of the different time scales from MJD0 (1858-11-17T00:00:00)
protected  byte precision
          The original precision = number of decimals + 1 (in specified unit); it's 0 when only month is known.
static java.lang.String[] prefix
          Conversion of time: time in unit = mjd*factor + offset
protected  byte unit
          The original choice of the date (index in 'prefix' table)
 
Constructor Summary
Astrotime()
          Default contructor (undefined time)
Astrotime(java.lang.String text)
          Constructor from a String.
 
Method Summary
static double B2J(double y)
          Conversion of a Besselian epoch to a Julian epoch
static double B2JD(double y)
          Conversion of a Besselian epoch to a Julian Date
 void dump(java.lang.String title)
          Dump the time contents.
 double getByr()
          Get the time expressed in Besselian yr
 double getJD()
          Get the time expressed in JD
 double getJyr()
          Get the time expressed in Julian yr
 double getMJD()
          Get the time expressed in MJD (JD-2400000.5)
 long getTime()
          Get the time expressed in milliseconds since 1 Jan 1970
static double J2B(double y)
          Conversion of a Julian epoch to a Besselian epoch
static double J2JD(double y)
          Conversion of a Julian epoch to a Julian Date
static double JD2B(double jd)
          Conversion of a Julian Date to a Besselian epoch
static double JD2J(double jd)
          Conversion of a Julian Date to a Julian epoch
static double JD2MJD(double jd)
          Conversion of a JD to MJD
static long JD2ms(double jd)
          Conversion of a Julian Date to a Milliseconds since 1 January 1970
static void JD2YMD(double jd, int[] ymd)
          Conversion of a Julian Date into a calendar year/month/day.
static double MJD2JD(double mjd)
          Conversion of a MJD to JD
static double ms2JD(long ms)
          Conversion of a calendar time expressed in Milliseconds to a Julian Date
 int parse(java.lang.String text, int offset)
          Interpret a string for a time.
 boolean parsing(Parsing t)
          Interpret a string for a time.
 void set(double mjd)
          Set the time from MJD.
 void set(long ms)
          Set the time from milliseconds.
 void set(java.lang.String text)
          Set the time from a String.
 java.lang.String toString()
          Get the time expressed in milliseconds since 1 Jan 1970
 java.lang.String toString(java.lang.String unit)
          Edit the time in the specified choice.
static double YMD2JD(int year, int month, int day)
          Conversion of a calendar date into a Julian Date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mjd

protected double mjd
The actual date/epoch is stored as MJD value (JD-2400000.5)


unit

protected byte unit
The original choice of the date (index in 'prefix' table)


precision

protected byte precision
The original precision = number of decimals + 1 (in specified unit); it's 0 when only month is known.


ed

public static Editing ed
The default choices of the edition for this class


Byr

public static final double Byr
Value of Besselian Year in days

See Also:
Constant Field Values

Jyr

public static final double Jyr
Value of the Julian Year in days

See Also:
Constant Field Values

JD_J2000

public static final double JD_J2000
Julian date of J2000 epoch

See Also:
Constant Field Values

JD_B1900

public static final double JD_B1900
Julian date of B1900 epoch

See Also:
Constant Field Values

JD_1970

public static final double JD_1970
Julian date of 1 Jan 1970

See Also:
Constant Field Values

JD_MJD0

public static final double JD_MJD0
Modified Julian date

See Also:
Constant Field Values

prefix

public static final java.lang.String[] prefix
Conversion of time: time in unit = mjd*factor + offset


offset

public static final double[] offset
Origin of the different time scales from MJD0 (1858-11-17T00:00:00)

Constructor Detail

Astrotime

public Astrotime()
Default contructor (undefined time)


Astrotime

public Astrotime(java.lang.String text)
          throws java.text.ParseException
Constructor from a String.

Parameters:
text - Sting expression of an Astrotime. Valid input values can be "Byyyy...", "Jyyyy...", "JDxxx" or "MJD..."
Throws:
java.text.ParseException - when text can't be interpreted.
Method Detail

J2JD

public static final double J2JD(double y)
Conversion of a Julian epoch to a Julian Date

Parameters:
y - Julian epoch
Returns:
Julian Date

B2JD

public static final double B2JD(double y)
Conversion of a Besselian epoch to a Julian Date

Parameters:
y - Besselian epoch
Returns:
Julian date

YMD2JD

public static final double YMD2JD(int year,
                                  int month,
                                  int day)
Conversion of a calendar date into a Julian Date. Note that if month=0, day may represent the day-in-year. When month is outside range 0..11, it's assumed to be January.

Parameters:
year - Year number
month - Month number, range 0=January to 11=December
day - Day number, range 1 to 31
Returns:
Julian Date

JD2YMD

public static final void JD2YMD(double jd,
                                int[] ymd)
Conversion of a Julian Date into a calendar year/month/day. When month is outside range 0..11, it's assumed to be January.

Parameters:
jd - Julian date
ymd - array on return with year month day. year=ymd[0], month=ymd[1](range 0..1), day=ymd[2](range 1..31). Day in year (range 1..366) is given as ymd[1] if ymd has 2 elements, ymd[3] if 4 elements.

ms2JD

public static final double ms2JD(long ms)
Conversion of a calendar time expressed in Milliseconds to a Julian Date

Parameters:
ms - UTC millisconds got e.g. via Calendar.getTimeInMillis()
Returns:
Julian Date

MJD2JD

public static final double MJD2JD(double mjd)
Conversion of a MJD to JD

Parameters:
mjd - Modified Julian Date
Returns:
Milliseconds e.g. to set date via Calendar.setTimeInMillis()

JD2J

public static final double JD2J(double jd)
Conversion of a Julian Date to a Julian epoch

Parameters:
jd - Julian Date
Returns:
Julian epoch

JD2B

public static final double JD2B(double jd)
Conversion of a Julian Date to a Besselian epoch

Parameters:
jd - Julian Date
Returns:
Besselian epoch

JD2ms

public static final long JD2ms(double jd)
Conversion of a Julian Date to a Milliseconds since 1 January 1970

Parameters:
jd - Julian Date
Returns:
Milliseconds e.g. to set date via Calendar.setTimeInMillis()

JD2MJD

public static final double JD2MJD(double jd)
Conversion of a JD to MJD

Parameters:
jd - Julian Date
Returns:
Modified Julian Date = JD - 2400000.5

B2J

public static final double B2J(double y)
Conversion of a Besselian epoch to a Julian epoch

Parameters:
y - Besselian epoch
Returns:
Julian epoch

J2B

public static final double J2B(double y)
Conversion of a Julian epoch to a Besselian epoch

Parameters:
y - Julian epoch
Returns:
Besselian epoch

dump

public final void dump(java.lang.String title)
Dump the time contents.


parsing

public boolean parsing(Parsing t)
Interpret a string for a time.

Parameters:
t - Text to interpret as a Parsing object
Returns:
true if something could be interpretated.

parse

public int parse(java.lang.String text,
                 int offset)
Interpret a string for a time. Accepts a time surrounded by brackets, or preceded by , /

Parameters:
text - String expression of an Astrotime
offset - Where to start in the text
Returns:
the number of bytes interpretated (offset if an error)

set

public void set(double mjd)
Set the time from MJD.

Parameters:
mjd - Date/time in MJD (JD-2400000.5)

set

public void set(long ms)
Set the time from milliseconds.

Parameters:
ms - Date/Time in milliseconds. (e.g. value returned from Calendar.getTimeInMillis()). The default edition is in JD, with 8 decimals.

set

public void set(java.lang.String text)
         throws java.text.ParseException
Set the time from a String. Valid times are "Byyyy...", "Jyyyy...", "JDxxx" or "MJD..." eventually surrounded by brackets, or preceded by , /

Parameters:
text - Sting expression of an Astrotime
Throws:
java.text.ParseException - when text can't be interpreted.

getMJD

public double getMJD()
Get the time expressed in MJD (JD-2400000.5)


getJyr

public double getJyr()
Get the time expressed in Julian yr


getByr

public double getByr()
Get the time expressed in Besselian yr


getJD

public double getJD()
Get the time expressed in JD


getTime

public long getTime()
Get the time expressed in milliseconds since 1 Jan 1970


toString

public java.lang.String toString(java.lang.String unit)
Edit the time in the specified choice.

Parameters:
unit - One of the possibilities "JD" "MJD" "J" "B" "ms"

toString

public java.lang.String toString()
Get the time expressed in milliseconds since 1 Jan 1970

Overrides:
toString in class java.lang.Object