public final class GlobalPositioningSystemDate extends Object implements Comparable<GlobalPositioningSystemDate>, IEquatable<GlobalPositioningSystemDate>, IEquatableEpsilon<GlobalPositioningSystemDate>, ImmutableValueType
GlobalPositioningSystemTime
(get
) time standard.
Internally, this class stores the date as a week number, a day of the week, and a number
of seconds into the day. This enables it to represent a date with the same precision as
the JulianDate
type.
Modifier and Type | Field and Description |
---|---|
static JulianDate |
JulianDateOfEpoch
The GPS epoch of 6 January 1980 00:00:00 UTC expressed as a
JulianDate in the GlobalPositioningSystemTime (get ). |
static int |
WeekWrapValue
The number of weeks after which the week count wraps around to zero.
|
Constructor and Description |
---|
GlobalPositioningSystemDate()
Initializes a new instance.
|
GlobalPositioningSystemDate(GregorianDate date)
Initializes a new instance from a
GregorianDate . |
GlobalPositioningSystemDate(int week,
DayOfWeek dayOfWeek,
double secondsOfDay)
Initializes a new instance from a week number, a day of the week, and a number of seconds into the day.
|
GlobalPositioningSystemDate(int week,
double secondsOfWeek)
Initializes a new instance from a week number and a number of seconds into the week.
|
GlobalPositioningSystemDate(int year,
int dayOfYear,
int hour,
int minute,
int second)
Initializes a new instance from the time parameters found in a
PerformanceAssessmentRecord . |
GlobalPositioningSystemDate(JulianDate date)
Initializes a new instance from a
JulianDate . |
GlobalPositioningSystemDate(ZonedDateTime date)
Initializes a new instance from a
ZonedDateTime . |
Modifier and Type | Method and Description |
---|---|
GlobalPositioningSystemDate |
add(Duration duration)
Adds a
Duration to this date, producing a new date. |
static GlobalPositioningSystemDate |
add(GlobalPositioningSystemDate left,
Duration right)
Adds a
Duration to a GlobalPositioningSystemDate , producing a new date. |
GlobalPositioningSystemDate |
addDays(double days)
Adds the specified number of days to this date and returns the new date.
|
GlobalPositioningSystemDate |
addSeconds(double seconds)
Adds the specified number of seconds to this date and returns the new date.
|
int |
compareTo(GlobalPositioningSystemDate other)
Compares this instance with another instance of the same type.
|
static boolean |
equals(GlobalPositioningSystemDate left,
GlobalPositioningSystemDate right)
Returns
true if the two instances are exactly equal. |
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
boolean |
equalsEpsilon(GlobalPositioningSystemDate other,
double epsilon)
Returns true if this date is within
epsilon seconds of the
specified date. |
boolean |
equalsType(GlobalPositioningSystemDate other)
Indicates whether another instance of this type is exactly equal to this instance.
|
DayOfWeek |
getDayOfWeek()
Gets the day of the week.
|
double |
getKPoints()
Gets the K-Points (15-minute segments) since the most recent GPS epoch.
|
int |
getRolloverCount()
Gets the number of times that the GPS week counter has rolled over since
GlobalPositioningSystemDate.JulianDateOfEpoch . |
JulianDate |
getRolloverDate()
Gets the most recent rollover of the GPS week counter.
|
double |
getSecondsOfDay()
Gets the elapsed whole and fractional seconds since the start of the day.
|
double |
getSecondsOfWeek()
Gets the elapsed whole and fractional seconds since the start of the week.
|
double |
getTotalDays()
Gets the total number of whole and fractional days that have elapsed since
GlobalPositioningSystemDate.JulianDateOfEpoch . |
double |
getTotalDaysSinceRollover()
Gets the total number of whole and fractional days that have elapsed since
RolloverDate (get ). |
int |
getWeek()
Gets the week number, which is the number of weeks since January 6, 1980.
|
int |
getWeekSinceRollover()
Gets the week number since the most recent GPS week rollover.
|
long |
getZCounts()
Gets the Z-Counts (1.5 second segments) since the most recent GPS Epoch.
|
static boolean |
greaterThan(GlobalPositioningSystemDate left,
GlobalPositioningSystemDate right)
Returns true if
left occurs after right . |
static boolean |
greaterThanOrEqual(GlobalPositioningSystemDate left,
GlobalPositioningSystemDate right)
Returns true if
left occurs after or at the same time as right . |
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
static boolean |
lessThan(GlobalPositioningSystemDate left,
GlobalPositioningSystemDate right)
Returns true if
left occurs before right . |
static boolean |
lessThanOrEqual(GlobalPositioningSystemDate left,
GlobalPositioningSystemDate right)
Returns true if
left occurs before or at the same time as right . |
double |
minutesDifference(GlobalPositioningSystemDate other)
Computes the number of minutes that have elapsed from this date to the
other date. |
static boolean |
notEquals(GlobalPositioningSystemDate left,
GlobalPositioningSystemDate right)
Returns
true if the two instances are not exactly equal. |
double |
secondsDifference(GlobalPositioningSystemDate other)
Computes the number of seconds that have elapsed from this date to the
other date. |
GlobalPositioningSystemDate |
subtract(Duration duration)
Subtracts a
Duration from this date, producing a new date. |
Duration |
subtract(GlobalPositioningSystemDate subtrahend)
Subtracts another date from this date.
|
static GlobalPositioningSystemDate |
subtract(GlobalPositioningSystemDate left,
Duration right)
Subtracts a
Duration from a date, yielding a new GlobalPositioningSystemDate . |
static Duration |
subtract(GlobalPositioningSystemDate left,
GlobalPositioningSystemDate right)
Subtracts a date from another date, yielding a
Duration . |
ZonedDateTime |
toDateTime()
Converts this GPS Time to a
ZonedDateTime with a default time standard of Global Positioning System Time. |
JulianDate |
toJulianDate()
Returns a
JulianDate that is equivalent to this instance. |
String |
toString()
Returns the value of this GPS Time in
RolloverCount (get ):WeekSinceRollover (get ):SecondsOfWeek (get ), where
RolloverCount (get ) is the number of times that the GPS week counter has rolled over since
GlobalPositioningSystemDate.JulianDateOfEpoch . |
@Nonnull public static final JulianDate JulianDateOfEpoch
JulianDate
in the GlobalPositioningSystemTime
(get
).public static final int WeekWrapValue
public GlobalPositioningSystemDate()
public GlobalPositioningSystemDate(int year, int dayOfYear, int hour, int minute, int second)
PerformanceAssessmentRecord
.year
- The year.dayOfYear
- The Julian day of year.hour
- The hour.minute
- The minute.second
- The Second.ArgumentOutOfRangeException
- Thrown when the parameter dayOfYear
is not between 1 and 366 inclusive.public GlobalPositioningSystemDate(@Nonnull JulianDate date)
JulianDate
.date
- The JulianDate
from which to create this instance.ArgumentOutOfRangeException
- Thrown if the given date is prior to the GlobalPositioningSystemDate.JulianDateOfEpoch
.public GlobalPositioningSystemDate(@Nonnull ZonedDateTime date)
ZonedDateTime
.date
- The ZonedDateTime
object from which to create this instance.ArgumentOutOfRangeException
- Thrown if the given date is prior to the GlobalPositioningSystemDate.JulianDateOfEpoch
.public GlobalPositioningSystemDate(@Nonnull GregorianDate date)
GregorianDate
.date
- The ZonedDateTime
object from which to create this instance.ArgumentOutOfRangeException
- Thrown if the given date is prior to the GlobalPositioningSystemDate.JulianDateOfEpoch
.public GlobalPositioningSystemDate(int week, double secondsOfWeek)
week
- The GPS reference week number. Must be counted from the initial GPS Epoch (Jan 6, 1980).secondsOfWeek
- The number of seconds into the week, counted from Sunday (the first day of the week) at midnight.public GlobalPositioningSystemDate(int week, @Nonnull DayOfWeek dayOfWeek, double secondsOfDay)
week
- The GPS reference week number. Must be counted from the initial GPS Epoch (Jan 6, 1980).dayOfWeek
- The day of the week.secondsOfDay
- The number of seconds into the day, counted from midnight.public final int getWeek()
public final int getWeekSinceRollover()
public final int getRolloverCount()
GlobalPositioningSystemDate.JulianDateOfEpoch
.public final double getSecondsOfWeek()
public final double getSecondsOfDay()
public final double getTotalDays()
GlobalPositioningSystemDate.JulianDateOfEpoch
.public final double getTotalDaysSinceRollover()
RolloverDate
(get
).public final double getKPoints()
public final long getZCounts()
@Nonnull public final JulianDate getRolloverDate()
WeekSinceRollover
(get
) is relative to this date.@Nonnull public final JulianDate toJulianDate()
JulianDate
that is equivalent to this instance.JulianDate
that is equivalent to this date.@Nonnull public final ZonedDateTime toDateTime()
ZonedDateTime
with a default time standard of Global Positioning System Time.ZonedDateTime
.public String toString()
RolloverCount
(get
):WeekSinceRollover
(get
):SecondsOfWeek
(get
), where
RolloverCount
(get
) is the number of times that the GPS week counter has rolled over since
GlobalPositioningSystemDate.JulianDateOfEpoch
.public final boolean equalsType(@Nonnull GlobalPositioningSystemDate other)
For two dates to be considered equal, the Week
(get
)
and DayOfWeek
(get
) properties must be identical and the difference
between the SecondsOfDay
(get
) properties must be less than 1.0e-10.
equalsType
in interface IEquatable<GlobalPositioningSystemDate>
other
- The instance to compare to this instance.true
if other
represents the same value as this instance; otherwise false
.public boolean equals(Object obj)
For two dates to be considered equal, the Week
(get
)
and DayOfWeek
(get
) properties must be identical and the difference
between the SecondsOfDay
(get
) properties must be less than 1.0e-10.
equals
in class Object
obj
- The object to compare to this instance.true
if obj
is an instance of this type and represents the same value as this instance; otherwise false
.Object.hashCode()
,
HashMap
public static boolean equals(@Nonnull GlobalPositioningSystemDate left, @Nonnull GlobalPositioningSystemDate right)
true
if the two instances are exactly equal.
For two dates to be considered equal, the Week
(get
)
and DayOfWeek
(get
) properties must be identical and the difference
between the SecondsOfDay
(get
) properties must be less than 1.0e-10.
left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
represents the same value as right
; otherwise false
.public static boolean notEquals(@Nonnull GlobalPositioningSystemDate left, @Nonnull GlobalPositioningSystemDate right)
true
if the two instances are not exactly equal.
For two dates to be considered equal, the Week
(get
)
and DayOfWeek
(get
) properties must be identical and the difference
between the SecondsOfDay
(get
) properties must be less than 1.0e-10.
left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
does not represent the same value as right
; otherwise false
.public final boolean equalsEpsilon(@Nonnull GlobalPositioningSystemDate other, double epsilon)
epsilon
seconds of the
specified date. That is, in order for the dates to be considered equal (and for
this function to return true), the absolute value of the difference between them, in
seconds, must be less than or equal to epsilon
.equalsEpsilon
in interface IEquatableEpsilon<GlobalPositioningSystemDate>
other
- The date to compare to this date.epsilon
- The largest difference between the dates, in seconds, such that they will be considered equal.public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public final int compareTo(@Nonnull GlobalPositioningSystemDate other)
compareTo
in interface Comparable<GlobalPositioningSystemDate>
other
- An object to compare with this instance.Value | Meaning |
---|---|
Less than zero |
This instance is less than other .
|
Zero |
This instance is equal to other .
|
Greater than zero |
This instance is greater than other .
|
public static boolean lessThan(@Nonnull GlobalPositioningSystemDate left, @Nonnull GlobalPositioningSystemDate right)
left
occurs before right
.left
- The date on the left side.right
- The date on the right side.true
if the left
is less than right
; otherwise false
.public static boolean greaterThan(@Nonnull GlobalPositioningSystemDate left, @Nonnull GlobalPositioningSystemDate right)
left
occurs after right
.left
- The date on the left side.right
- The date on the right side.true
if the left
is greater than right
; otherwise false
.public static boolean lessThanOrEqual(@Nonnull GlobalPositioningSystemDate left, @Nonnull GlobalPositioningSystemDate right)
left
occurs before or at the same time as right
.left
- The date on the left side.right
- The date on the right side.true
if left
occurs before or at the same time as right
; otherwise false
.public static boolean greaterThanOrEqual(@Nonnull GlobalPositioningSystemDate left, @Nonnull GlobalPositioningSystemDate right)
left
occurs after or at the same time as right
.left
- The date on the left side.right
- The date on the right side.true
if left
occurs after or at the same time as right
; otherwise false
.public final double secondsDifference(@Nonnull GlobalPositioningSystemDate other)
other
date.
This method subtracts the date on which it is called from the other
date and returns the number of seconds between them.
other
- The other date, which is the end of the interval.public final double minutesDifference(@Nonnull GlobalPositioningSystemDate other)
other
date.
This method subtracts the date on which it is called from the other
date and returns the number of minutes between them.
other
- The other date, which is the end of the interval.@Nonnull public final GlobalPositioningSystemDate add(@Nonnull Duration duration)
Duration
to this date, producing a new date.
If the Standard
(get
) of duration
is not
GlobalPositioningSystemTime
(get
), the date will be converted
to the duration's time standard before performing the addition. Then, the resulting
date will be converted to GlobalPositioningSystemTime
(get
) before
it is returned.
duration
- The duration to add.@Nonnull public final Duration subtract(@Nonnull GlobalPositioningSystemDate subtrahend)
This method subtracts the subtrahend
date from this
date and returns the Duration
between them.
subtrahend
- The date to subtract from this date.@Nonnull public final GlobalPositioningSystemDate subtract(@Nonnull Duration duration)
Duration
from this date, producing a new date.
If the Standard
(get
) of duration
is not
GlobalPositioningSystemTime
(get
), the date will be
converted to the duration's time standard before performing the subtraction. Then,
the resulting date will be converted to
GlobalPositioningSystemTime
(get
) before it is returned.
duration
- The duration to subtract.@Nonnull public final GlobalPositioningSystemDate addSeconds(double seconds)
seconds
- The number of seconds.@Nonnull public final GlobalPositioningSystemDate addDays(double days)
days
- The number of days.@Nonnull public static Duration subtract(@Nonnull GlobalPositioningSystemDate left, @Nonnull GlobalPositioningSystemDate right)
Duration
.
This method subtracts the right
date from the left
date and returns the Duration
between them.
left
- The minuend.right
- The subtrahend.left
minus right
.@Nonnull public static GlobalPositioningSystemDate subtract(@Nonnull GlobalPositioningSystemDate left, @Nonnull Duration right)
Duration
from a date, yielding a new GlobalPositioningSystemDate
.
If the Standard
(get
) of right
is not
GlobalPositioningSystemTime
(get
), the date will be converted
to the duration's time standard before performing the subtraction. Then, the resulting
date will be converted to GlobalPositioningSystemTime
(get
)
before it is returned.
left
- The minuend.right
- The subtrahend.left
minus right
. The time standard will be the same as the time standard of the subtrahend.@Nonnull public static GlobalPositioningSystemDate add(@Nonnull GlobalPositioningSystemDate left, @Nonnull Duration right)
Duration
to a GlobalPositioningSystemDate
, producing a new date.
If the Standard
(get
) of right
is not
GlobalPositioningSystemTime
(get
), the date will be converted
to the duration's time standard before performing the addition. Then, the resulting
date will be to GlobalPositioningSystemTime
(get
) before it is returned.
left
- The date.right
- The duration.