Package javax.time

Class SystemUTCRules

java.lang.Object
javax.time.UTCRules
javax.time.SystemUTCRules
All Implemented Interfaces:
Serializable

final class SystemUTCRules extends UTCRules implements Serializable
System default UTC rules.

SystemUTCRules is immutable and thread-safe.

  • Field Details

  • Constructor Details

    • SystemUTCRules

      private SystemUTCRules()
      Restricted constructor.
  • Method Details

    • readResolve

      private 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 of
      leapAdjustment - the leap seconds to add/remove at the end of the day, either -1 or 1
      Throws:
      IllegalArgumentException - if the leap adjustment is invalid
      IllegalArgumentException - 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
    • getName

      public String getName()
      Description copied from class: UTCRules
      The name of these rules.
      Specified by:
      getName in class UTCRules
      Returns:
      the name, never null
    • 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 or 1.

      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 class UTCRules
      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 class UTCRules
      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 class UTCRules
      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: UTCRules
      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.

      Specified by:
      convertToUTC in class UTCRules
      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 to
      offset - the new offset after the leap
      Returns:
      the TAI seconds