Top Description Inners Fields Constructors Methods
org.threeten.extra.scale

pack-priv final Class SystemUtcRules

extends UtcRules
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.BufferedReader, .IOException, .InputStreamReader, .Serializable, .StreamCorruptedException, java.net.URL, java.nio.charset.StandardCharsets, java.time.LocalDate, java.time.temporal.JulianFields, java.util.ArrayList, .Arrays, .ConcurrentModificationException, .Enumeration, .List, java.util.concurrent.atomic.AtomicReference, java.util.regex.Matcher, .Pattern, java.util.stream.Collectors

System default UTC rules.

Implementation Requirements:

This class is immutable and thread-safe.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SystemUtcRules.Data

Data holder.

Field Summary

Modifier and TypeField and Description
private AtomicReference<SystemUtcRules.Data>
dataRef

The table of leap second dates.

pack-priv static final SystemUtcRules
INSTANCE

Singleton.

private static final Pattern
LEAP_FILE_FORMAT

Leap second file format.

private static final String
LEAP_SECONDS_TXT

The leap seconds config file.

private static final long
serialVersionUID

Serialization version.

Inherited from org.threeten.extra.scale.UtcRules:
NANOS_PER_SECONDOFFSET_MJD_EPOCHOFFSET_MJD_TAISECS_PER_DAY

Constructor Summary

AccessConstructor and Description
private
SystemUtcRules()

Restricted constructor.

Method Summary

Modifier and TypeMethod and Description
public UtcInstant
convertToUtc(TaiInstant
the TAI instant to convert, not null
taiInstant
)

Implements abstract org.threeten.extra.scale.UtcRules.convertToUtc.

Converts a TaiInstant to a UtcInstant.

public int
getLeapSecondAdjustment(long
the date as a Modified Julian Day (number of days from the epoch of 1858-11-17)
mjDay
)

Implements abstract org.threeten.extra.scale.UtcRules.getLeapSecondAdjustment.

Gets the leap second adjustment on the specified date.

public long[]
getLeapSecondDates()

Implements abstract org.threeten.extra.scale.UtcRules.getLeapSecondDates.

Gets all known leap second dates.

public String
getName()

Implements abstract org.threeten.extra.scale.UtcRules.getName.

The name of these rules.

public int
getTaiOffset(long
the date as a Modified Julian Day (number of days from the epoch of 1858-11-17)
mjDay
)

Implements abstract org.threeten.extra.scale.UtcRules.getTaiOffset.

Gets the offset to TAI on the specified date.

private static SystemUtcRules.Data

Returns:

the list of loaded rules, not null
loadLeapSeconds
()

Loads the rules from files in the class loader, often jar files.

private static SystemUtcRules.Data
loadLeapSeconds(URL
the jar file to load, not null
url
)

Loads the leap second rules from a URL, often in a jar file.

private Object

Returns:

the resolved instance, not null
readResolve
()

Resolves singleton.

pack-priv void
register(long
the Modified Julian Day that the leap second occurs at the end of
mjDay
,
int
the leap seconds to add/remove at the end of the day, either -1 or 1
leapAdjustment
)

Adds a new leap second to these rules.

private static long

Returns:

the TAI seconds
tai
(long
the MJD that the leap second is added to
changeMjd
,
int
the new offset after the leap
offset
)

Gets the TAI seconds for the start of the day following the day passed in.

Inherited from org.threeten.extra.scale.UtcRules:
convertToInstantconvertToInstantconvertToTaiconvertToTaiconvertToUtcregisterLeapSecondsystemtoStringvalidateModifiedJulianDay

Field Detail

dataRefback to summary
private AtomicReference<SystemUtcRules.Data> dataRef

The table of leap second dates.

INSTANCEback to summary
pack-priv static final SystemUtcRules INSTANCE

Singleton.

LEAP_FILE_FORMATback to summary
private static final Pattern LEAP_FILE_FORMAT

Leap second file format.

LEAP_SECONDS_TXTback to summary
private static final String LEAP_SECONDS_TXT

The leap seconds config file.

serialVersionUIDback to summary
private static final long serialVersionUID

Serialization version.

Constructor Detail

SystemUtcRulesback to summary
private SystemUtcRules()

Restricted constructor.

Method Detail

convertToUtcback to summary
public UtcInstant convertToUtc(TaiInstant taiInstant)

Implements abstract org.threeten.extra.scale.UtcRules.convertToUtc.

Doc from org.threeten.extra.scale.UtcRules.convertToUtc.

Converts a TaiInstant to a UtcInstant.

This method converts from the TAI to the UTC time-scale using the leap-second rules of the implementation.

Parameters
taiInstant:TaiInstant

the TAI instant to convert, not null

Returns:UtcInstant

the converted UTC instant, not null

Annotations
@Override
getLeapSecondAdjustmentback to summary
public int getLeapSecondAdjustment(long mjDay)

Implements abstract org.threeten.extra.scale.UtcRules.getLeapSecondAdjustment.

Doc from org.threeten.extra.scale.UtcRules.getLeapSecondAdjustment.

Gets the leap second adjustment on the specified date.

The UTC standard restricts the adjustment on any day to -1 or 1.

Any leap seconds are added to, or removed from, the end of the specified date.

If the UTC specification is altered to allow multiple leap seconds at once, then the result of this method would return a number with an absolute value greater than one.

Parameters
mjDay:long

the date as a Modified Julian Day (number of days from the epoch of 1858-11-17)

Returns:int

the number of seconds added, or removed, from the date, either -1 or 1

Annotations
@Override
getLeapSecondDatesback to summary
public long[] getLeapSecondDates()

Implements abstract org.threeten.extra.scale.UtcRules.getLeapSecondDates.

Doc from org.threeten.extra.scale.UtcRules.getLeapSecondDates.

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.

Returns:long[]

an array of leap second dates expressed as Modified Julian Day values, not null

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.threeten.extra.scale.UtcRules.getName.

Doc from org.threeten.extra.scale.UtcRules.getName.

The name of these rules.

Returns:String

the name, not null

Annotations
@Override
getTaiOffsetback to summary
public int getTaiOffset(long mjDay)

Implements abstract org.threeten.extra.scale.UtcRules.getTaiOffset.

Doc from org.threeten.extra.scale.UtcRules.getTaiOffset.

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.

Parameters
mjDay:long

the date as a Modified Julian Day (number of days from the epoch of 1858-11-17)

Returns:int

the TAI offset in seconds

Annotations
@Override
loadLeapSecondsback to summary
private static SystemUtcRules.Data loadLeapSeconds()

Loads the rules from files in the class loader, often jar files.

Returns:SystemUtcRules.Data

the list of loaded rules, not null

Exceptions
Exception:
if an error occurs
loadLeapSecondsback to summary
private static SystemUtcRules.Data loadLeapSeconds(URL url) throws ClassNotFoundException, IOException

Loads the leap second rules from a URL, often in a jar file.

Parameters
url:URL

the jar file to load, not null

Exceptions
Exception:
if an error occurs
readResolveback to summary
private Object readResolve()

Resolves singleton.

Returns:Object

the resolved instance, not null

registerback to summary
pack-priv void register(long mjDay, int leapAdjustment)

Adds a new leap second to these rules.

Parameters
mjDay:long

the Modified Julian Day that the leap second occurs at the end of

leapAdjustment:int

the leap seconds to add/remove at the end of the day, either -1 or 1

Exceptions
IllegalArgumentException:
  • if the leap adjustment is invalid
  • if the day is before or equal the last known leap second day and the definition does not match a previously registered leap
ConcurrentModificationException:
if another thread updates the rules at the same time
taiback to summary
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:long

the MJD that the leap second is added to

offset:int

the new offset after the leap

Returns:long

the TAI seconds

org.threeten.extra.scale back to summary

private final Class SystemUtcRules.Data

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Data holder.

Field Summary

Modifier and TypeField and Description
private final long[]
dates

The table of leap second date when the leap second occurs.

private final int[]
offsets

The table of TAI offset after the leap second.

private static final long
serialVersionUID

Serialization version.

private final long[]
taiSeconds

The table of TAI second when the new offset starts.

Constructor Summary

AccessConstructor and Description
private
Data(long[] dates, int[] offsets, long[] taiSeconds)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

The modified Julian Date of the newest leap second
getNewestDate
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

datesback to summary
private final long[] dates

The table of leap second date when the leap second occurs.

offsetsback to summary
private final int[] offsets

The table of TAI offset after the leap second.

serialVersionUIDback to summary
private static final long serialVersionUID

Serialization version.

taiSecondsback to summary
private final long[] taiSeconds

The table of TAI second when the new offset starts.

Constructor Detail

Databack to summary
private Data(long[] dates, int[] offsets, long[] taiSeconds)

Constructor.

Method Detail

getNewestDateback to summary
public long getNewestDate()
Returns:long

The modified Julian Date of the newest leap second