Class SystemUTCRules
- java.lang.Object
-
- javax.time.UTCRules
-
- javax.time.SystemUTCRules
-
- All Implemented Interfaces:
java.io.Serializable
final class SystemUTCRules extends UTCRules implements java.io.Serializable
System default UTC rules.SystemUTCRules is immutable and thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSystemUTCRules.DataData holder.
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<SystemUTCRules.Data>dataRefThe table of leap second dates.(package private) static SystemUTCRulesINSTANCESingleton.private static longserialVersionUIDSerialization version.-
Fields inherited from class javax.time.UTCRules
NANOS_PER_SECOND, OFFSET_MJD_EPOCH, OFFSET_MJD_TAI, SECS_PER_DAY
-
-
Constructor Summary
Constructors Modifier Constructor Description privateSystemUTCRules()Restricted constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected UTCInstantconvertToUTC(TAIInstant taiInstant)Converts aTAIInstantto aUTCInstant.intgetLeapSecondAdjustment(long mjDay)Gets the leap second adjustment on the specified date.long[]getLeapSecondDates()Gets all known leap second dates.java.lang.StringgetName()The name of these rules.intgetTAIOffset(long mjDay)Gets the offset to TAI on the specified date.private static SystemUTCRules.DataloadLeapSeconds()Loads the leap seconds from file.private java.lang.ObjectreadResolve()Resolves 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 javax.time.UTCRules
convertToInstant, convertToTAI, convertToUTC, registerSystemLeapSecond, system, toString
-
-
-
-
Field Detail
-
INSTANCE
static final SystemUTCRules INSTANCE
Singleton.
-
serialVersionUID
private static final long serialVersionUID
Serialization version.- See Also:
- Constant Field Values
-
dataRef
private java.util.concurrent.atomic.AtomicReference<SystemUTCRules.Data> dataRef
The table of leap second dates.
-
-
Method Detail
-
readResolve
private java.lang.Object 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:
java.lang.IllegalArgumentException- if the leap adjustment is invalidjava.lang.IllegalArgumentException- if the day is before or equal the last known leap second day and the definition does not match a previously registered leapjava.util.ConcurrentModificationException- if another thread updates the rules at the same time
-
getName
public java.lang.String getName()
Description copied from class:UTCRulesThe name of these rules.
-
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
protected UTCInstant convertToUTC(TAIInstant taiInstant)
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
private static SystemUTCRules.Data 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
-
-