Class DecimalTime
In astronomical aplications it is usual to use a decimal time with range [0, 1). This implementation uses the "civilan" time, with 0 set at midnight instead of noon. To get the astronomical time of the day, just add 0.5.
Please note that these routines ignore the timezone.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalasBigDecimal(TemporalAccessor temporal) Returns a decimal time from a temporal accessor object as a BigDecimal value.static doubleasDouble(TemporalAccessor temporal) Returns a decimal time from a temporal accessor object as a double value.static LocalDateTimeparseDateTime(CharSequence text) Parses a string in the following format into a LocalDateTime object:1957-10-04.81static LocalTimetoLocalTime(double dt) Converts the given decimal time to a LocalTime object.static LocalTimeConverts the given decimal time to a LocalTime object.
-
Method Details
-
asDouble
Returns a decimal time from a temporal accessor object as a double value.The temporal accessor must support the field
ChronoField.NANO_OF_DAY- Parameters:
temporal- temporal accessor to use- Returns:
- a double value representing the decimal time.
-
asBigDecimal
Returns a decimal time from a temporal accessor object as a BigDecimal value.The temporal accessor must support the field
ChronoField.NANO_OF_DAY- Parameters:
temporal- temporal accessor to use- Returns:
- a BigDecimal value representing the decimal time.
-
toLocalTime
Converts the given decimal time to a LocalTime object.- Parameters:
dt- decimal time- Returns:
- the equivalent LocalTime.
-
toLocalTime
Converts the given decimal time to a LocalTime object.- Parameters:
dt- decimal time- Returns:
- the equivalent LocalTime.
-
parseDateTime
Parses a string in the following format into a LocalDateTime object:1957-10-04.81This is useful as some texts give date-time references in this format. The above string will be then translated to a LocalDateTime with the content:
1957-10-04T19:26:24.It is possible to use negative years. Please note that the floating-point part is mandatory, so for example to indicate the midnight of November 1st, 2000, the correct format would be:
2000-11-01.0, or even2000-11-1.0.Both "." and "," are accepted as separators.
- Parameters:
text- the string to parse.- Returns:
- a LocalDateTime object representing the given time
-