java.lang.Object
esa.opensf.osfi.TimeValue
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionfinal byteDay of month, 1 to 28/29/30/31 depending on the month/year combination.final byteHour, 0 to 23.final byteMinute, 0 to 59.final byteMonth, 1 to 12.final intFraction of the second in nanosecond precision, 0 to 999_999_999.final byteSecond, 0 to 60 (to allow for leap seconds, which are not verified).final shortYear number, 1 to 9999. -
Constructor Summary
ConstructorsConstructorDescriptionTimeValue(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 TypeMethodDescriptionintValues are compared field by field from most to least significant.booleanReturnstrueif theotherobject compares equal tothis, that is, if it is also of typeTimeValueand all its fields match those ofthis.inthashCode()Returns a hash code composed of all the fields in the instance.static TimeValueParse the value of (a single element of) a TIME parameter, which must be in CCSDS ASCII calendar segmented time code format.toString()
-
Field Details
-
year
public final short yearYear number, 1 to 9999. -
month
public final byte monthMonth, 1 to 12. -
dom
public final byte domDay of month, 1 to 28/29/30/31 depending on the month/year combination. -
hour
public final byte hourHour, 0 to 23. -
minute
public final byte minuteMinute, 0 to 59. -
sec
public final byte secSecond, 0 to 60 (to allow for leap seconds, which are not verified). -
nanosec
public final int nanosecFraction 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
-
compareTo
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:
compareToin interfaceComparable<TimeValue>- Returns:
- negative value if
thisis ordered beforeother, positive value if the order is the inverse, and zero if the two values compare equal.
-
equals
Returnstrueif theotherobject compares equal tothis, that is, if it is also of typeTimeValueand all its fields match those ofthis. 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. -
hashCode
public int hashCode()Returns a hash code composed of all the fields in the instance. -
parse
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.
-