jodd.datetime
Class JulianDateStamp

java.lang.Object
  extended by jodd.datetime.JulianDateStamp
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class JulianDateStamp
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Julian Date stamp, for high precision calculations. Julian date is a real number and it basically consist of two parts: integer and fraction. Integer part carries date information, fraction carries time information.

The Julian day or Julian day number (JDN) is the (integer) number of days that have elapsed since Monday, January 1, 4713 BC in the proleptic Julian calendar 1. That day is counted as Julian day zero. Thus the multiples of 7 are Mondays. Negative values can also be used.

The Julian Date (JD) is the number of days (with decimal fraction of the day) that have elapsed since 12 noon Greenwich Mean Time (UT or TT) of that day. Rounding to the nearest integer gives the Julian day number. For calculations that will have time precision of 1e-3 seconds, both fraction and integer part must have enough numerics in it. The problem is that integer part is big and, on the other hand fractional is small, and since final julian date is a sum of this two values, some fraction numerals may be lost. Therefore, for higher precision both fractional and intger part of julian date real number has to be preserved.

See Also:
TimeUtil, JDateTime, todo Add switches to MJD, TJD..., Serialized Form

Field Summary
 double fraction
          Fraction part of the Julian Date (JD).
 int integer
          Integer part of the Julian Date (JD).
 
Constructor Summary
JulianDateStamp()
          Default empty constructor.
JulianDateStamp(java.math.BigDecimal bd)
          Creates JD from BigDecimal.
JulianDateStamp(double jd)
          Creates JD from a double.
JulianDateStamp(int i, double f)
          Creates JD from both integer and fractional part using normalization.
 
Method Summary
 JulianDateStamp add(double delta)
          Adds a double to current instance.
 JulianDateStamp add(JulianDateStamp jds)
          Adds a JD to current instance.
protected  java.lang.Object clone()
           
 double doubleValue()
          Returns double value of JD.
 boolean equals(java.lang.Object object)
           
 int getJulianDayNumber()
          Returns JDN.
 int hashCode()
           
 void set(int i, double f)
          Sets integer and fractional part with normalization.
 JulianDateStamp sub(double delta)
          Subtracts a double from current instance.
 JulianDateStamp sub(JulianDateStamp jds)
          Subtracts a JD from current instance.
 java.math.BigDecimal toBigDecimal()
          Returns BigDecimal value of JD.
 java.lang.String toString()
          Returns string representation of JD.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

integer

public int integer
Integer part of the Julian Date (JD).


fraction

public double fraction
Fraction part of the Julian Date (JD). Should be always in [0.0, 1.0) range.

Constructor Detail

JulianDateStamp

public JulianDateStamp()
Default empty constructor.


JulianDateStamp

public JulianDateStamp(double jd)
Creates JD from a double.


JulianDateStamp

public JulianDateStamp(int i,
                       double f)
Creates JD from both integer and fractional part using normalization. Normalization occurs when fractional part is out of range.

Parameters:
i - integer part
f - fractional part should be in range [0.0, 1.0)
See Also:
set(int, double)

JulianDateStamp

public JulianDateStamp(java.math.BigDecimal bd)
Creates JD from BigDecimal.

Method Detail

getJulianDayNumber

public int getJulianDayNumber()
Returns JDN. Note that JDN is not equals to integer. It is calculated by rounding to the nearest integer.


doubleValue

public double doubleValue()
Returns double value of JD. CAUTION: double values may not be suit for precision math due to loss of precision.


toBigDecimal

public java.math.BigDecimal toBigDecimal()
Returns BigDecimal value of JD.


toString

public java.lang.String toString()
Returns string representation of JD.

Overrides:
toString in class java.lang.Object
Returns:
julian integer as string

add

public JulianDateStamp add(JulianDateStamp jds)
Adds a JD to current instance.


add

public JulianDateStamp add(double delta)
Adds a double to current instance.


sub

public JulianDateStamp sub(JulianDateStamp jds)
Subtracts a JD from current instance.


sub

public JulianDateStamp sub(double delta)
Subtracts a double from current instance.


set

public void set(int i,
                double f)
Sets integer and fractional part with normalization. Normalization means that if double is out of range, values will be correctly fixed.


equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clone

protected java.lang.Object clone()
Overrides:
clone in class java.lang.Object


Copyright ©2008 Jodd Team