org.orekit.time
Class DateTimeComponents

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

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

Holder for date and time components.

This class is a simple holder with no processing methods.

Instance of this class are guaranteed to be immutable.

Author:
Luc Maisonobe
See Also:
AbsoluteDate, DateComponents, TimeComponents, Serialized Form

Constructor Summary
DateTimeComponents(DateComponents date, TimeComponents time)
          Build a new instance from its components.
DateTimeComponents(DateTimeComponents reference, double offset)
          Build an instance from a seconds offset with respect to another one.
DateTimeComponents(int year, int month, int day)
          Build an instance from raw level components.
DateTimeComponents(int year, int month, int day, int hour, int minute, double second)
          Build an instance from raw level components.
DateTimeComponents(int year, Month month, int day)
          Build an instance from raw level components.
DateTimeComponents(int year, Month month, int day, int hour, int minute, double second)
          Build an instance from raw level components.
 
Method Summary
 int compareTo(DateTimeComponents other)
          
 boolean equals(Object other)
          
 DateComponents getDate()
          Get the date component.
 TimeComponents getTime()
          Get the time component.
 int hashCode()
          
 double offsetFrom(DateTimeComponents dateTime)
          Compute the seconds offset between two instances.
static DateTimeComponents parseDateTime(String string)
          Parse a string in ISO-8601 format to build a date/time.
 String toString()
          Return a string representation of this pair.
protected  String toString(int precision, boolean isTimeNearLeapSecond)
          Return a string representation of this pair.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateTimeComponents

public DateTimeComponents(DateComponents date,
                          TimeComponents time)
Build a new instance from its components.

Parameters:
date - date component
time - time component

DateTimeComponents

public DateTimeComponents(int year,
                          int month,
                          int day,
                          int hour,
                          int minute,
                          double second)
                   throws IllegalArgumentException
Build an instance from raw level components.

Parameters:
year - year number (may be 0 or negative for BC years)
month - month number from 1 to 12
day - day number from 1 to 31
hour - hour number from 0 to 23
minute - minute number from 0 to 59
second - second number from 0.0 to 60.0 (excluded)
Throws:
IllegalArgumentException - if inconsistent arguments are given (parameters out of range, february 29 for non-leap years, dates during the gregorian leap in 1582 ...)

DateTimeComponents

public DateTimeComponents(int year,
                          Month month,
                          int day,
                          int hour,
                          int minute,
                          double second)
                   throws IllegalArgumentException
Build an instance from raw level components.

Parameters:
year - year number (may be 0 or negative for BC years)
month - month enumerate
day - day number from 1 to 31
hour - hour number from 0 to 23
minute - minute number from 0 to 59
second - second number from 0.0 to 60.0 (excluded)
Throws:
IllegalArgumentException - if inconsistent arguments are given (parameters out of range, february 29 for non-leap years, dates during the gregorian leap in 1582 ...)

DateTimeComponents

public DateTimeComponents(int year,
                          int month,
                          int day)
                   throws IllegalArgumentException
Build an instance from raw level components.

The hour is set to 00:00:00.000.

Parameters:
year - year number (may be 0 or negative for BC years)
month - month number from 1 to 12
day - day number from 1 to 31
Throws:
IllegalArgumentException - if inconsistent arguments are given (parameters out of range, february 29 for non-leap years, dates during the gregorian leap in 1582 ...)

DateTimeComponents

public DateTimeComponents(int year,
                          Month month,
                          int day)
                   throws IllegalArgumentException
Build an instance from raw level components.

The hour is set to 00:00:00.000.

Parameters:
year - year number (may be 0 or negative for BC years)
month - month enumerate
day - day number from 1 to 31
Throws:
IllegalArgumentException - if inconsistent arguments are given (parameters out of range, february 29 for non-leap years, dates during the gregorian leap in 1582 ...)

DateTimeComponents

public DateTimeComponents(DateTimeComponents reference,
                          double offset)
Build an instance from a seconds offset with respect to another one.

Parameters:
reference - reference date/time
offset - offset from the reference in seconds
See Also:
offsetFrom(DateTimeComponents)
Method Detail

parseDateTime

public static DateTimeComponents parseDateTime(String string)
Parse a string in ISO-8601 format to build a date/time.

The supported formats are all date formats supported by DateComponents.parseDate(String) and all time formats supported by TimeComponents.parseTime(String) separated by the standard time separator 'T', or date components only (in which case a 00:00:00 hour is implied). Typical examples are 2000-01-01T12:00:00Z or 1976W186T210000.

Parameters:
string - string to parse
Returns:
a parsed date/time
Throws:
IllegalArgumentException - if string cannot be parsed

offsetFrom

public double offsetFrom(DateTimeComponents dateTime)
Compute the seconds offset between two instances.

Parameters:
dateTime - dateTime to subtract from the instance
Returns:
offset in seconds between the two instants (positive if the instance is posterior to the argument)
See Also:
DateTimeComponents(DateTimeComponents, double)

getDate

public DateComponents getDate()
Get the date component.

Returns:
date component

getTime

public TimeComponents getTime()
Get the time component.

Returns:
time component

compareTo

public int compareTo(DateTimeComponents other)

Specified by:
compareTo in interface Comparable<DateTimeComponents>

equals

public boolean equals(Object other)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()
Return a string representation of this pair.

The format used is ISO8601.

Overrides:
toString in class Object
Returns:
string representation of this pair

toString

protected String toString(int precision,
                          boolean isTimeNearLeapSecond)
Return a string representation of this pair.

The format used is ISO8601.

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:
a string representation of the instance, in ISO-8601 format with a seconds accuracy defined as input


Copyright © 2017 CNES. All Rights Reserved.