public class DateTimeComponents extends Object implements Serializable, Comparable<DateTimeComponents>
This class is a simple holder with no processing methods.
Instance of this class are guaranteed to be immutable.
AbsoluteDate
,
DateComponents
,
TimeComponents
,
Serialized FormModifier and Type | Field and Description |
---|---|
static DateTimeComponents |
JULIAN_EPOCH
The Julian Epoch.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
toString(int minuteDuration)
Return a string representation of this date-time, rounded to millisecond
precision.
|
String |
toString(int minuteDuration,
int fractionDigits)
Return a string representation of this date-time, rounded to the given precision.
|
String |
toStringRfc3339()
Represent the given date and time as a string according to the format in RFC 3339.
|
String |
toStringWithoutUtcOffset()
Get a string representation of the date-time without the offset from UTC.
|
public static final DateTimeComponents JULIAN_EPOCH
TimeScales.getJulianEpoch()
public DateTimeComponents(DateComponents date, TimeComponents time)
date
- date componenttime
- time componentpublic DateTimeComponents(int year, int month, int day, int hour, int minute, double second) throws IllegalArgumentException
year
- year number (may be 0 or negative for BC years)month
- month number from 1 to 12day
- day number from 1 to 31hour
- hour number from 0 to 23minute
- minute number from 0 to 59second
- second number from 0.0 to 60.0 (excluded)IllegalArgumentException
- if inconsistent arguments
are given (parameters out of range, february 29 for non-leap years,
dates during the gregorian leap in 1582 ...)public DateTimeComponents(int year, Month month, int day, int hour, int minute, double second) throws IllegalArgumentException
year
- year number (may be 0 or negative for BC years)month
- month enumerateday
- day number from 1 to 31hour
- hour number from 0 to 23minute
- minute number from 0 to 59second
- second number from 0.0 to 60.0 (excluded)IllegalArgumentException
- if inconsistent arguments
are given (parameters out of range, february 29 for non-leap years,
dates during the gregorian leap in 1582 ...)public DateTimeComponents(int year, int month, int day) throws IllegalArgumentException
The hour is set to 00:00:00.000.
year
- year number (may be 0 or negative for BC years)month
- month number from 1 to 12day
- day number from 1 to 31IllegalArgumentException
- if inconsistent arguments
are given (parameters out of range, february 29 for non-leap years,
dates during the gregorian leap in 1582 ...)public DateTimeComponents(int year, Month month, int day) throws IllegalArgumentException
The hour is set to 00:00:00.000.
year
- year number (may be 0 or negative for BC years)month
- month enumerateday
- day number from 1 to 31IllegalArgumentException
- if inconsistent arguments
are given (parameters out of range, february 29 for non-leap years,
dates during the gregorian leap in 1582 ...)public DateTimeComponents(DateTimeComponents reference, double offset)
reference
- reference date/timeoffset
- offset from the reference in secondsoffsetFrom(DateTimeComponents)
public static DateTimeComponents parseDateTime(String string)
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.
string
- string to parseIllegalArgumentException
- if string cannot be parsedpublic double offsetFrom(DateTimeComponents dateTime)
dateTime
- dateTime to subtract from the instanceDateTimeComponents(DateTimeComponents, double)
public DateComponents getDate()
public TimeComponents getTime()
public int compareTo(DateTimeComponents other)
compareTo
in interface Comparable<DateTimeComponents>
public String toString()
The format used is ISO8601 including the UTC offset.
public String toStringWithoutUtcOffset()
toString(int, int)
,
toStringRfc3339()
public String toString(int minuteDuration)
The format used is ISO8601 including the UTC offset.
minuteDuration
- 60, 61, or 62 seconds depending on the date being close to a
leap second introduction and the magnitude of the leap
second.toString(int, int)
public String toString(int minuteDuration, int fractionDigits)
The format used is ISO8601 including the UTC offset.
minuteDuration
- 59, 60, 61, or 62 seconds depending on the date being close
to a leap second introduction and the magnitude of the leap
second.fractionDigits
- the number of digits to include after the decimal point in
the string representation of the seconds. The date and time
is first rounded as necessary. fractionDigits
must
be greater than or equal to 0
.toStringRfc3339()
,
toStringWithoutUtcOffset()
public String toStringRfc3339()
RFC3339 is unable to represent BC years, years of 10000 or more, time zone offsets of 100 hours or more, or NaN. In these cases the value returned from this method will not be valid RFC3339 format.
AbsoluteDate.toStringRfc3339(TimeScale)
,
toString(int, int)
,
toStringWithoutUtcOffset()
Copyright © 2002-2021 CS GROUP. All rights reserved.