Class TimeComponents

    • Field Detail

      • H00

        public static final TimeComponents H00
        Constant for commonly used hour 00:00:00.
      • H12

        public static final TimeComponents H12
        Constant for commonly used hour 12:00:00.
    • Constructor Detail

      • TimeComponents

        public TimeComponents​(int hour,
                              int minute,
                              double second)
                       throws IllegalArgumentException
        Build a time from its clock elements.

        Note that seconds between 60.0 (inclusive) and 61.0 (exclusive) are allowed in this method, since they do occur during leap seconds introduction in the UTC time scale.

        Parameters:
        hour - hour number from 0 to 23
        minute - minute number from 0 to 59
        second - second number from 0.0 to 61.0 (excluded)
        Throws:
        IllegalArgumentException - if inconsistent arguments are given (parameters out of range)
      • TimeComponents

        public TimeComponents​(int hour,
                              int minute,
                              double second,
                              int minutesFromUTC)
                       throws IllegalArgumentException
        Build a time from its clock elements.

        Note that seconds between 60.0 (inclusive) and 61.0 (exclusive) are allowed in this method, since they do occur during leap seconds introduction in the UTC time scale.

        Parameters:
        hour - hour number from 0 to 23
        minute - minute number from 0 to 59
        second - second number from 0.0 to 61.0 (excluded)
        minutesFromUTC - offset between the specified date and UTC, as an integral number of minutes, as per ISO-8601 standard
        Throws:
        IllegalArgumentException - if inconsistent arguments are given (parameters out of range)
        Since:
        7.2
      • TimeComponents

        public TimeComponents​(int secondInDayA,
                              double secondInDayB)
                       throws OrekitIllegalArgumentException
        Build a time from the second number within the day.

        The second number is defined here as the sum secondInDayA + secondInDayB from 0.0 to Constants.JULIAN_DAY (excluded). The two parameters are used for increased accuracy.

        This constructor is always in UTC (i.e. will return 0).

        Parameters:
        secondInDayA - first part of the second number
        secondInDayB - last part of the second number
        Throws:
        OrekitIllegalArgumentException - if seconds number is out of range
    • Method Detail

      • parseTime

        public static TimeComponents parseTime​(String string)
        Parse a string in ISO-8601 format to build a time.

        The supported formats are:

        • basic and extended format local time: hhmmss, hh:mm:ss (with optional decimals in seconds)
        • optional UTC time: hhmmssZ, hh:mm:ssZ
        • optional signed hours UTC offset: hhmmss+HH, hhmmss-HH, hh:mm:ss+HH, hh:mm:ss-HH
        • optional signed basic hours and minutes UTC offset: hhmmss+HHMM, hhmmss-HHMM, hh:mm:ss+HHMM, hh:mm:ss-HHMM
        • optional signed extended hours and minutes UTC offset: hhmmss+HH:MM, hhmmss-HH:MM, hh:mm:ss+HH:MM, hh:mm:ss-HH:MM

        As shown by the list above, only the complete representations defined in section 4.2 of ISO-8601 standard are supported, neither expended representations nor representations with reduced accuracy are supported.

        Parameters:
        string - string to parse
        Returns:
        a parsed time
        Throws:
        IllegalArgumentException - if string cannot be parsed
      • getHour

        public int getHour()
        Get the hour number.
        Returns:
        hour number from 0 to 23
      • getMinute

        public int getMinute()
        Get the minute number.
        Returns:
        minute minute number from 0 to 59
      • getSecond

        public double getSecond()
        Get the seconds number.
        Returns:
        second second number from 0.0 to 61.0 (excluded). Note that 60 ≤ second < 61 only occurs during a leap second.
      • getMinutesFromUTC

        public int getMinutesFromUTC()
        Get the offset between the specified date and UTC.

        The offset is always an integral number of minutes, as per ISO-8601 standard.

        Returns:
        offset in minutes between the specified date and UTC
        Since:
        7.2
      • getSecondsInLocalDay

        public double getSecondsInLocalDay()
        Get the second number within the local day, without applying the offset from UTC.
        Returns:
        second number from 0.0 to Constants.JULIAN_DAY
        Since:
        7.2
        See Also:
        getSecondsInUTCDay()
      • toString

        public String toString()
        Get a string representation of the time.
        Overrides:
        toString in class Object
        Returns:
        string representation of the time
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object