Class DecimalTime

java.lang.Object
eu.fastipletonis.astro.temporal.DecimalTime

public class DecimalTime extends Object
Conversion routines for the decimal time.

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 Details

    • asDouble

      public static double asDouble(TemporalAccessor temporal)
      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

      public static BigDecimal asBigDecimal(TemporalAccessor temporal)
      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

      public static LocalTime toLocalTime(double dt)
      Converts the given decimal time to a LocalTime object.
      Parameters:
      dt - decimal time
      Returns:
      the equivalent LocalTime.
    • toLocalTime

      public static LocalTime toLocalTime(BigDecimal dt)
      Converts the given decimal time to a LocalTime object.
      Parameters:
      dt - decimal time
      Returns:
      the equivalent LocalTime.
    • parseDateTime

      public static LocalDateTime parseDateTime(CharSequence text)
      Parses a string in the following format into a LocalDateTime object: 1957-10-04.81

      This 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 even 2000-11-1.0.

      Both "." and "," are accepted as separators.

      Parameters:
      text - the string to parse.
      Returns:
      a LocalDateTime object representing the given time