Class TimeValue

java.lang.Object
esa.opensf.osfi.TimeValue
All Implemented Interfaces:
Comparable<TimeValue>

public final class TimeValue extends Object implements Comparable<TimeValue>
Class that represents the parsed value of a TIME-formatted parameter. The values stored are interpreted as a proleptic Gregorian date between 0001-01-01T00:00:00Z and 9999-12:31T23:59:60.999999999Z. The range of the fields is checked on construction, but the validity of a leap-second is not.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final byte
    Day of month, 1 to 28/29/30/31 depending on the month/year combination.
    final byte
    Hour, 0 to 23.
    final byte
    Minute, 0 to 59.
    final byte
    Month, 1 to 12.
    final int
    Fraction of the second in nanosecond precision, 0 to 999_999_999.
    final byte
    Second, 0 to 60 (to allow for leap seconds, which are not verified).
    final short
    Year number, 1 to 9999.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeValue(int year, int month, int dom, int hour, int minute, int sec, int nanosec)
    Create an instance representing the given point in time.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Values are compared field by field from most to least significant.
    boolean
    equals(Object other)
    Returns true if the other object compares equal to this, that is, if it is also of type TimeValue and all its fields match those of this.
    int
    Returns a hash code composed of all the fields in the instance.
    static TimeValue
    Parse the value of (a single element of) a TIME parameter, which must be in CCSDS ASCII calendar segmented time code format.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • year

      public final short year
      Year number, 1 to 9999.
    • month

      public final byte month
      Month, 1 to 12.
    • dom

      public final byte dom
      Day of month, 1 to 28/29/30/31 depending on the month/year combination.
    • hour

      public final byte hour
      Hour, 0 to 23.
    • minute

      public final byte minute
      Minute, 0 to 59.
    • sec

      public final byte sec
      Second, 0 to 60 (to allow for leap seconds, which are not verified).
    • nanosec

      public final int nanosec
      Fraction of the second in nanosecond precision, 0 to 999_999_999.
  • Constructor Details

    • TimeValue

      public TimeValue(int year, int month, int dom, int hour, int minute, int sec, int nanosec)
      Create an instance representing the given point in time. This constructor uses int arguments so that it can be called with literal values. However, the provided values are range-checked, and the constructor throws if any values are out of the ranges indicated below. Caveats:
      • The length of months (esp. February) is considered using a proleptic Gregorian calendar.
      • A value of 60 is allowed for the seconds in order to represent an added leap second. However, this class does not have access to a leap second database, nor does it compute anything. A value of 60 is accepted as-is and not checked.
      Parameters:
      year - Year number, from 1 to 9999 inclusive.
      month - Month number, from 1 to 12.
      dom - Day of month, from 1 to the appropriate length according to the year.
      hour - Hour of day, from 0 to 23.
      minute - Minute of hour, from 0 to 59.
      sec - Second of minute, from 0 to 60 to allow for leap seconds.
      nanosec - Fraction of second in ns resolution, from 0 to 999_999_999.
      Throws:
      IllegalArgumentException - If a value is out of range.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      this object as a CCSDS ASCII time code type "A" (month plus day of month).
    • compareTo

      public int compareTo(TimeValue o)
      Values are compared field by field from most to least significant. No adaptations are performed, so month=3 and dom=31 is less-than month=4 and dom=0.
      Specified by:
      compareTo in interface Comparable<TimeValue>
      Returns:
      negative value if this is ordered before other, positive value if the order is the inverse, and zero if the two values compare equal.
    • equals

      public boolean equals(Object other)
      Returns true if the other object compares equal to this, that is, if it is also of type TimeValue and all its fields match those of this. Two instances are equal if all their field values are exactly equal. No conversions or adaptations are performed so month=4 and dom=0 is different from month=3 and dom=31.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code composed of all the fields in the instance.
      Overrides:
      hashCode in class Object
    • parse

      public static TimeValue parse(String s)
      Parse the value of (a single element of) a TIME parameter, which must be in CCSDS ASCII calendar segmented time code format.
      Parameters:
      s - String value
      Returns:
      Parsed time code value.
      Throws:
      IllegalArgumentException - If the string has an unsupported format.