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 SystemUTCRulesSingleton.private static final longSerialization version.Fields inherited from class UTCRules
NANOS_PER_SECOND, OFFSET_MJD_EPOCH, OFFSET_MJD_TAI, SECS_PER_DAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected UTCInstantconvertToUTC(TAIInstant taiInstant) Converts aTAIInstantto aUTCInstant.intgetLeapSecondAdjustment(long mjDay) Gets the leap second adjustment on the specified date.long[]Gets all known leap second dates.getName()The name of these rules.intgetTAIOffset(long mjDay) Gets the offset to TAI on the specified date.private static SystemUTCRules.DataLoads the leap seconds from file.private ObjectResolves singleton.(package private) voidregisterLeapSecond(long mjDay, int leapAdjustment) Adds a new leap second to these rules.private static longtai(long changeMjd, int offset) Gets the TAI seconds for the start of the day following the day passed in.Methods inherited from class 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
-
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
-
getLeapSecondAdjustment
public int getLeapSecondAdjustment(long mjDay) Description copied from class:UTCRulesGets the leap second adjustment on the specified date.The UTC standard restricts the adjustment to a day to
-1or1.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:
getLeapSecondAdjustmentin 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:UTCRulesGets 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:
getTAIOffsetin 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:UTCRulesGets 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:
getLeapSecondDatesin classUTCRules- Returns:
- an array of leap second dates expressed as Modified Julian Day values, not null
-
convertToUTC
Description copied from class:UTCRulesConverts aTAIInstantto aUTCInstant.This method converts from the TAI to the UTC time-scale using the leap-second rules of the implementation.
- Specified by:
convertToUTCin 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
-