Class JulianDayHelper
The standard Java implementation for JulianFields.JULIAN_DAY only
implements long results. Astronomical calculations often require a Julian
Day able to handle the time of the day as well.
Please notice that this implementation completely ignores the time zone. The user should ensure the use of the appropriate time frame.
The Julian day is calculated according to Meeus' algorithm explained in Chapter 7.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalgetBigDecimalFrom(TemporalAccessor temporal) Returns the Julian day from the given temporal accessor as a BigDecimal value.static doublegetDoubleFrom(TemporalAccessor temporal) Returns the Julian day from the given temporal accessor as a double floating-point value.static LocalDateTimegetLocalDateTimeFrom(double jd) Converts a Julian Day into a calendar date, storing the result in aLocalDateTimeobject.static LocalDateTimeConverts a Julian Day into a calendar date, storing the result in aLocalDateTimeobject.static booleanisSupported(TemporalAccessor temporal) Checks if the given temporal accessor can be used to extract a Julian day.
-
Method Details
-
isSupported
Checks if the given temporal accessor can be used to extract a Julian day.The following fields are checked:
Both
LocalDateTimeandZonedDateTimesatisfy these prerequisites.- Parameters:
temporal- the temporal accessor to be checked- Returns:
trueif all the required fields are supported- See Also:
-
getBigDecimalFrom
Returns the Julian day from the given temporal accessor as a BigDecimal value.The temporal accessor must support the following fields:
Both
LocalDateTimeandZonedDateTimesatisfy these prerequisites.- Parameters:
temporal- the temporal accessor- Returns:
- the Julian Day as a BigDecimal value
-
getDoubleFrom
Returns the Julian day from the given temporal accessor as a double floating-point value.The temporal accessor must support the following fields:
Both
LocalDateTimeandZonedDateTimesatisfy these prerequisites.- Parameters:
temporal- the temporal accessor- Returns:
- the Julian Day as a value of type double
-
getLocalDateTimeFrom
Converts a Julian Day into a calendar date, storing the result in aLocalDateTimeobject.The conversion uses the procedure described in Chapter 7 to convert a Julian Day back to a calendar date.
- Parameters:
jd- the Julian Day to convert.- Returns:
- a LocalDatTime object representing the Julian Day
- Throws:
DateTimeException- if a negative Julian Day is passed as an argument
-
getLocalDateTimeFrom
Converts a Julian Day into a calendar date, storing the result in aLocalDateTimeobject.The conversion uses the procedure described in Chapter 7 to convert a Julian Day back to a calendar date.
- Parameters:
jd- the Julian Day to convert.- Returns:
- a LocalDateTime object representing the Julian Day
- Throws:
DateTimeException- if a negative Julian Day is passed as an argument
-