org.orekit.time
Class TimeComponents

java.lang.Object
  extended by org.orekit.time.TimeComponents
All Implemented Interfaces:
Serializable, Comparable<TimeComponents>

public class TimeComponents
extends Object
implements Serializable, Comparable<TimeComponents>

Class representing a time within the day broken up as hour, minute and second components.

Instances of this class are guaranteed to be immutable.

Author:
Luc Maisonobe
See Also:
DateComponents, DateTimeComponents, Serialized Form

Field Summary
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 Summary
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 hour, int minute, double second)
          Build a time from its clock elements.
 
Method Summary
 int compareTo(TimeComponents other)
          
 boolean equals(Object other)
          
 int getHour()
          Get the hour number.
 int getMinute()
          Get the minute number.
 double getSecond()
          Get the seconds number.
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SECONDS_PRECISION

public static final int DEFAULT_SECONDS_PRECISION
Default digit number of the seconds fractional part.

See Also:
Constant Field Values

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(double secondInDay)
Build a time from the second number within the day.

Parameters:
secondInDay - second number from 0.0 to Constants.JULIAN_DAY (excluded)

TimeComponents

public TimeComponents(int secondInDayA,
                      double secondInDayB)
               throws IllegalArgumentException
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.

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

parseTime

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

The supported formats are:

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.

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.

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 60.0 (excluded)

getSecondsInDay

public double getSecondsInDay()
Get the second number within the day.

Returns:
second number from 0.0 to Constants.JULIAN_DAY

toString

public String toString()
Get a string representation of the time.

Overrides:
toString in class Object
Returns:
string representation of the time

toString

protected String toString(int precision,
                          boolean isTimeNearLeapSecond)
                   throws IllegalArgumentException
Get a string representation of the time.

Parameters:
precision - digit number of the seconds fractional part
isTimeNearLeapSecond - 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.
Returns:
string representation of the time
Throws:
IllegalArgumentException - if inconsistent arguments are given (negative precision)

compareTo

public int compareTo(TimeComponents other)

Specified by:
compareTo in interface Comparable<TimeComponents>

equals

public boolean equals(Object other)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object


Copyright © 2017 CNES. All Rights Reserved.