public class JulianDateStamp
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
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 digits 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 integer part of julian date real number has to be preserved.
This class stores the unmodified fraction part, but not all digits are significant! For 1e-3 seconds precision, only 8 digits after the decimal point are significant.
TimeUtil
,
JDateTime
,
DateTimeStamp
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected double |
fraction
Fraction part of the Julian Date (JD).
|
protected int |
integer
Integer part of the Julian Date (JD).
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
JulianDateStamp |
add(double delta)
Adds a double to current instance.
|
JulianDateStamp |
add(JulianDateStamp jds)
Adds a JD to current instance.
|
protected JulianDateStamp |
clone() |
int |
daysBetween(JulianDateStamp otherDate)
Calculates the number of days between two dates.
|
int |
daysSpan(JulianDateStamp otherDate)
Returns span between two days.
|
double |
doubleValue()
Returns
double value of JD. |
boolean |
equals(java.lang.Object object) |
double |
getFraction()
Returns the fraction part of Julian Date (JD).
|
int |
getInteger()
Returns integer part of the Julian Date (JD).
|
int |
getJulianDayNumber()
Returns JDN.
|
JulianDateStamp |
getModifiedJulianDate()
Returns Modified Julian Date (MJD), where date starts from midnight rather than noon.
|
JulianDateStamp |
getReducedJulianDate()
Returns Reduced Julian Date (RJD), used by astronomers.
|
int |
getSignificantFraction()
Calculates and returns significant fraction only as an int.
|
JulianDateStamp |
getTruncatedJulianDate()
Returns Truncated Julian Day (TJD), introduced by NASA for the space program.
|
int |
hashCode() |
void |
set(double jd) |
void |
set(int i,
double f)
Sets integer and fractional part with normalization.
|
void |
setModifiedJulianDate(double mjd) |
void |
setReducedJulianDate(double rjd) |
void |
setTruncatedJulianDate(double tjd) |
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.
|
protected int integer
protected double fraction
public JulianDateStamp()
public JulianDateStamp(double jd)
double
.public JulianDateStamp(int i, double f)
i
- integer partf
- fractional part should be in range [0.0, 1.0)set(int, double)
public JulianDateStamp(java.math.BigDecimal bd)
BigDecimal
.public int getInteger()
public double getFraction()
public int getSignificantFraction()
public int getJulianDayNumber()
integer
. It is calculated by
rounding to the nearest integer.public double doubleValue()
double
value of JD.
CAUTION: double values may not be suit for precision math due to
loss of precision.public java.math.BigDecimal toBigDecimal()
BigDecimal
value of JD.public java.lang.String toString()
toString
in class java.lang.Object
public JulianDateStamp add(JulianDateStamp jds)
public JulianDateStamp add(double delta)
public JulianDateStamp sub(JulianDateStamp jds)
public JulianDateStamp sub(double delta)
public void set(int i, double f)
public void set(double jd)
public int daysBetween(JulianDateStamp otherDate)
public int daysSpan(JulianDateStamp otherDate)
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected JulianDateStamp clone()
clone
in class java.lang.Object
public JulianDateStamp getReducedJulianDate()
public void setReducedJulianDate(double rjd)
public JulianDateStamp getModifiedJulianDate()
public void setModifiedJulianDate(double mjd)
public JulianDateStamp getTruncatedJulianDate()
public void setTruncatedJulianDate(double tjd)
Copyright © 2003-2013 Jodd Team