Class SystemUTCRules
- All Implemented Interfaces:
Serializable
SystemUTCRules is immutable and thread-safe.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AtomicReference
<SystemUTCRules.Data> The table of leap second dates.(package private) static final SystemUTCRules
Singleton.private static final long
Serialization version.Fields inherited from class javax.time.UTCRules
NANOS_PER_SECOND, OFFSET_MJD_EPOCH, OFFSET_MJD_TAI, SECS_PER_DAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected UTCInstant
convertToUTC
(TAIInstant taiInstant) Converts aTAIInstant
to aUTCInstant
.int
getLeapSecondAdjustment
(long mjDay) Gets the leap second adjustment on the specified date.long[]
Gets all known leap second dates.getName()
The name of these rules.int
getTAIOffset
(long mjDay) Gets the offset to TAI on the specified date.private static SystemUTCRules.Data
Loads the leap seconds from file.private Object
Resolves singleton.(package private) void
registerLeapSecond
(long mjDay, int leapAdjustment) Adds a new leap second to these rules.private static long
tai
(long changeMjd, int offset) Gets the TAI seconds for the start of the day following the day passed in.Methods inherited from class javax.time.UTCRules
convertToInstant, convertToTAI, convertToUTC, registerSystemLeapSecond, system, toString
-
Field Details
-
INSTANCE
Singleton. -
serialVersionUID
private static final long serialVersionUIDSerialization version.- See Also:
-
dataRef
The table of leap second dates.
-
-
Constructor Details
-
SystemUTCRules
private SystemUTCRules()Restricted constructor.
-
-
Method Details
-
readResolve
Resolves singleton.- Returns:
- the resolved instance, never null
-
registerLeapSecond
void registerLeapSecond(long mjDay, int leapAdjustment) Adds a new leap second to these rules.- Parameters:
mjDay
- the modified julian date that the leap second occurs at the end ofleapAdjustment
- the leap seconds to add/remove at the end of the day, either -1 or 1- Throws:
IllegalArgumentException
- if the leap adjustment is invalidIllegalArgumentException
- if the day is before or equal the last known leap second day and the definition does not match a previously registered leapConcurrentModificationException
- if another thread updates the rules at the same time
-
getName
Description copied from class:UTCRules
The name of these rules. -
getLeapSecondAdjustment
public int getLeapSecondAdjustment(long mjDay) Description copied from class:UTCRules
Gets the leap second adjustment on the specified date.The UTC standard restricts the adjustment to a day to
-1
or1
.Any leap seconds are added to, or removed from, the end of the specified date.
NOTE: If the UTC specification is altered to allow multiple leap seconds at once, then the result of this method would change.
- Specified by:
getLeapSecondAdjustment
in classUTCRules
- Parameters:
mjDay
- the date as a Modified Julian Day (number of days from the epoch of 1858-11-17)- Returns:
- the number of seconds added, or removed, from the date, either -1 or 1
-
getTAIOffset
public int getTAIOffset(long mjDay) Description copied from class:UTCRules
Gets the offset to TAI on the specified date.The TAI offset starts at 10 in 1972 and varies from then on based on the dates of leap seconds. The offset will apply for the whole of the date.
- Specified by:
getTAIOffset
in classUTCRules
- Parameters:
mjDay
- the date as a Modified Julian Day (number of days from the epoch of 1858-11-17)- Returns:
- the TAI offset in seconds
-
getLeapSecondDates
public long[] getLeapSecondDates()Description copied from class:UTCRules
Gets all known leap second dates.The dates are returned as Modified Julian Day values. The leap second is added to, or removed from, the end of the specified dates. The dates will be sorted from earliest to latest.
- Specified by:
getLeapSecondDates
in classUTCRules
- Returns:
- an array of leap second dates expressed as Modified Julian Day values, not null
-
convertToUTC
Description copied from class:UTCRules
Converts aTAIInstant
to aUTCInstant
.This method converts from the TAI to the UTC time-scale using the leap-second rules of the implementation.
- Specified by:
convertToUTC
in classUTCRules
- Parameters:
taiInstant
- the TAI instant to convert, not null- Returns:
- the converted UTC instant, not null
-
loadLeapSeconds
Loads the leap seconds from file.- Returns:
- an array of two arrays - leap seconds dates and amounts
-
tai
private static long tai(long changeMjd, int offset) Gets the TAI seconds for the start of the day following the day passed in.- Parameters:
changeMjd
- the MJD that the leap second is added tooffset
- the new offset after the leap- Returns:
- the TAI seconds
-