public class TimeComponents extends Object implements Serializable, Comparable<TimeComponents>
Instances of this class are guaranteed to be immutable.
DateComponents
,
DateTimeComponents
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SECONDS_PRECISION
Default digit number of the seconds fractional part.
|
static TimeComponents |
H00
Constant for commonly used hour 00:00:00.
|
static TimeComponents |
H12
Constant for commonly used hour 12:00:00.
|
Constructor and Description |
---|
TimeComponents(double secondInDay)
Build a time from the second number within the day.
|
TimeComponents(int secondInDayA,
double secondInDayB)
Build a time from the second number within the day.
|
TimeComponents(int hourIn,
int minuteIn,
double secondIn)
Build a time from its clock elements.
|
TimeComponents(int hourIn,
int minuteIn,
int secondIn,
double fracSecondsIn)
Build a time from its clock elements.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TimeComponents other) |
boolean |
equals(Object other) |
double |
getFractionSeconds()
Get the fractional part of seconds.
|
int |
getHour()
Get the hour number.
|
int |
getMinute()
Get the minute number.
|
double |
getSecond()
Get the seconds number (it includes the fractional part of seconds).
|
double |
getSecondsInDay()
Get the second number within the day.
|
int |
hashCode() |
static TimeComponents |
parseTime(String string)
Parse a string in ISO-8601 format to build a time.
|
String |
toString()
Get a string representation of the time.
|
protected String |
toString(int precision,
boolean isTimeNearLeapSecond)
Get a string representation of the time.
|
public static final int DEFAULT_SECONDS_PRECISION
public static final TimeComponents H00
public static final TimeComponents H12
public TimeComponents(int hourIn, int minuteIn, double secondIn)
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.
hourIn
- hour number from 0 to 23minuteIn
- minute number from 0 to 59secondIn
- second number from 0.0 to 61.0 (excluded)IllegalArgumentException
- if inconsistent arguments
are given (parameters out of range)public TimeComponents(int hourIn, int minuteIn, int secondIn, double fracSecondsIn)
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.
hourIn
- hour number from 0 to 23minuteIn
- minute number from 0 to 59secondIn
- second number from 0.0 to 61.0 (excluded)fracSecondsIn
- fractional part of secondsIllegalArgumentException
- if inconsistent arguments
are given (parameters out of range)public TimeComponents(double secondInDay)
secondInDay
- second number from 0.0 to Constants.JULIAN_DAY
(excluded)public TimeComponents(int secondInDayA, double secondInDayB)
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.
secondInDayA
- first part of the second numbersecondInDayB
- last part of the second numberIllegalArgumentException
- if seconds number is out of rangepublic static TimeComponents parseTime(String string)
The supported formats are:
As this class does not support time zones (because space flight dynamics uses time scales
with
offsets from UTC having sub-second accuracy), only UTC is zone is supported (and in fact ignored). It is the
responsibility of the AbsoluteDate
class to handle time scales appropriately.
string
- string to parseIllegalArgumentException
- if string cannot be parsedpublic int getHour()
public int getMinute()
public double getSecond()
public double getFractionSeconds()
public double getSecondsInDay()
public String toString()
protected String toString(int precision, boolean isTimeNearLeapSecond)
precision
- digit number of the seconds fractional partisTimeNearLeapSecond
- true if the date is inside or immediately before
a leap second. It is used to set the upper boundary of the current day:
23:59:60.99.. when true, 23:59:59.99.. when false.IllegalArgumentException
- if inconsistent arguments
are given (negative precision)public int compareTo(TimeComponents other)
compareTo
in interface Comparable<TimeComponents>
Copyright © 2017 CNES. All rights reserved.