Class CachedDateTimeZone


public final class CachedDateTimeZone extends StorableDateTimeZone
Improves the performance of requesting time zone offsets and name keys by caching the results. Time zones that have simple rules or are fixed should not be cached, as it is unlikely to improve performance.

CachedDateTimeZone is thread-safe and immutable.

Since:
1.0
Author:
Brian S O'Neill
  • Method Details

    • forZone

      public static CachedDateTimeZone forZone(StorableDateTimeZone zone)
      Returns a new CachedDateTimeZone unless given zone is already cached.
    • write

      public void write(StringBuilder sb)
      Specified by:
      write in class StorableDateTimeZone
    • getUncachedZone

      public DateTimeZone getUncachedZone()
      Returns the DateTimeZone being wrapped.
    • getOffset

      public int getOffset(long instant)
      Description copied from class: DateTimeZone
      Gets the millisecond offset to add to UTC to get local time.
      Specified by:
      getOffset in class DateTimeZone
      Parameters:
      instant - milliseconds from 1970-01-01T00:00:00Z to get the offset for
      Returns:
      the millisecond offset to add to UTC to get local time
    • getStandardOffset

      public int getStandardOffset(long instant)
      Description copied from class: DateTimeZone
      Gets the standard millisecond offset to add to UTC to get local time, when standard time is in effect.
      Specified by:
      getStandardOffset in class DateTimeZone
      Parameters:
      instant - milliseconds from 1970-01-01T00:00:00Z to get the offset for
      Returns:
      the millisecond offset to add to UTC to get local time
    • isFixed

      public boolean isFixed()
      Description copied from class: DateTimeZone
      Returns true if this time zone has no transitions.
      Specified by:
      isFixed in class DateTimeZone
      Returns:
      true if no transitions
    • nextTransition

      public long nextTransition(long instant)
      Description copied from class: DateTimeZone
      Advances the given instant to where the time zone offset or name changes. If the instant returned is exactly the same as passed in, then no changes occur after the given instant.
      Specified by:
      nextTransition in class DateTimeZone
      Parameters:
      instant - milliseconds from 1970-01-01T00:00:00Z
      Returns:
      milliseconds from 1970-01-01T00:00:00Z
    • previousTransition

      public long previousTransition(long instant)
      Description copied from class: DateTimeZone
      Retreats the given instant to where the time zone offset or name changes. If the instant returned is exactly the same as passed in, then no changes occur before the given instant.
      Specified by:
      previousTransition in class DateTimeZone
      Parameters:
      instant - milliseconds from 1970-01-01T00:00:00Z
      Returns:
      milliseconds from 1970-01-01T00:00:00Z
    • asZoneRules

      public ZoneRules asZoneRules()
      Specified by:
      asZoneRules in class DateTimeZone