public class JulianDate
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
,
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).
|
static JulianDate |
JD_1970
Julian Date for 1970-01-01T00:00:00 (Thursday).
|
static JulianDate |
JD_2001
Julian Date for 2001-01-01T00:00:00 (Monday).
|
Constructor and Description |
---|
JulianDate(java.math.BigDecimal bd)
Creates JD from
BigDecimal . |
JulianDate(double jd)
Creates JD from a
double . |
JulianDate(int i,
double f)
Creates JD from both integer and fractional part using normalization.
|
Modifier and Type | Method and Description |
---|---|
JulianDate |
add(double delta)
Adds a double delta value and returns a new instance.
|
JulianDate |
add(JulianDate jds)
Adds two JD and returns a new instance.
|
protected JulianDate |
clone() |
int |
daysBetween(JulianDate otherDate)
Calculates the number of days between two dates.
|
int |
daysSpan(JulianDate 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.
|
JulianDate |
getModifiedJulianDate()
Returns Modified Julian Date (MJD), where date starts from midnight rather than noon.
|
JulianDate |
getReducedJulianDate()
Returns Reduced Julian Date (RJD), used by astronomers.
|
int |
getSignificantFraction()
Calculates and returns significant fraction only as an int.
|
JulianDate |
getTruncatedJulianDate()
Returns Truncated Julian Day (TJD), introduced by NASA for the space program.
|
int |
hashCode() |
static JulianDate |
now() |
static JulianDate |
of(double value) |
static JulianDate |
of(int i,
double f) |
static JulianDate |
of(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond) |
static JulianDate |
of(java.time.LocalDate localDate) |
static JulianDate |
of(java.time.LocalDateTime localDateTime) |
static JulianDate |
of(long milliseconds) |
JulianDate |
sub(double delta)
Subtracts a double from current instance and returns a new instance.
|
JulianDate |
sub(JulianDate jds)
Subtracts a JD from current instance and returns a new instance.
|
java.math.BigDecimal |
toBigDecimal()
Returns
BigDecimal value of JD. |
java.time.LocalDateTime |
toLocalDateTime() |
long |
toMilliseconds()
Converts to milliseconds.
|
java.lang.String |
toString()
Returns string representation of JD.
|
public static final JulianDate JD_1970
public static final JulianDate JD_2001
protected int integer
protected double fraction
public JulianDate(double jd)
double
.public JulianDate(int i, double f)
i
- integer partf
- fractional part should be in range [0.0, 1.0)set(int, double)
public JulianDate(java.math.BigDecimal bd)
BigDecimal
.public static JulianDate of(double value)
public static JulianDate of(java.time.LocalDateTime localDateTime)
public static JulianDate of(java.time.LocalDate localDate)
public static JulianDate of(long milliseconds)
public static JulianDate of(int i, double f)
public static JulianDate of(int year, int month, int day, int hour, int minute, int second, int millisecond)
public static JulianDate now()
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 long toMilliseconds()
public java.time.LocalDateTime toLocalDateTime()
public JulianDate add(JulianDate jds)
public JulianDate add(double delta)
public JulianDate sub(JulianDate jds)
public JulianDate sub(double delta)
public int daysBetween(JulianDate otherDate)
public int daysSpan(JulianDate otherDate)
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected JulianDate clone()
clone
in class java.lang.Object
public JulianDate getReducedJulianDate()
public JulianDate getModifiedJulianDate()
public JulianDate getTruncatedJulianDate()
Copyright © 2003-present Jodd Team