Package org.h2.util

Class TimeZoneProvider

java.lang.Object
org.h2.util.TimeZoneProvider
Direct Known Subclasses:
TimeZoneProvider.Simple, TimeZoneProvider.WithTimeZone

public abstract class TimeZoneProvider extends Object
Provides access to time zone API.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
    Time zone provider with offset.
    (package private) static final class 
    Time zone provider with time zone.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    A small cache for timezone providers.
    private static final int
    The number of cache elements (needs to be a power of 2).
    static final TimeZoneProvider
    The UTC time zone provider.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the time zone provider for the system default time zone.
    abstract long
    getEpochSecondsFromLocal(long dateValue, long timeNanos)
    Calculates the epoch seconds from local date and time.
    abstract String
    Returns the ID of the time zone.
    abstract String
    getShortId(long epochSeconds)
    Get the standard time name or daylight saving time name of the time zone.
    abstract int
    getTimeZoneOffsetLocal(long dateValue, long timeNanos)
    Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.
    abstract int
    getTimeZoneOffsetUTC(long epochSeconds)
    Calculates the time zone offset in seconds for the specified EPOCH seconds.
    boolean
    Returns whether this is a simple time zone provider with a fixed offset from UTC.
    Returns the time zone provider with the specified name.
    ofOffset(int offset)
    Returns the time zone provider with the specified offset.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UTC

      public static final TimeZoneProvider UTC
      The UTC time zone provider.
    • CACHE

      public static TimeZoneProvider[] CACHE
      A small cache for timezone providers.
    • CACHE_SIZE

      private static final int CACHE_SIZE
      The number of cache elements (needs to be a power of 2).
      See Also:
  • Constructor Details

    • TimeZoneProvider

      public TimeZoneProvider()
  • Method Details

    • ofOffset

      public static TimeZoneProvider ofOffset(int offset)
      Returns the time zone provider with the specified offset.
      Parameters:
      offset - UTC offset in seconds
      Returns:
      the time zone provider with the specified offset
    • ofId

      public static TimeZoneProvider ofId(String id) throws RuntimeException
      Returns the time zone provider with the specified name.
      Parameters:
      id - the ID of the time zone
      Returns:
      the time zone provider with the specified name
      Throws:
      RuntimeException - if time zone with specified ID isn't known
    • getDefault

      public static TimeZoneProvider getDefault()
      Returns the time zone provider for the system default time zone.
      Returns:
      the time zone provider for the system default time zone
    • getTimeZoneOffsetUTC

      public abstract int getTimeZoneOffsetUTC(long epochSeconds)
      Calculates the time zone offset in seconds for the specified EPOCH seconds.
      Parameters:
      epochSeconds - seconds since EPOCH
      Returns:
      time zone offset in minutes
    • getTimeZoneOffsetLocal

      public abstract int getTimeZoneOffsetLocal(long dateValue, long timeNanos)
      Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.
      Parameters:
      dateValue - date value
      timeNanos - nanoseconds since midnight
      Returns:
      time zone offset in minutes
    • getEpochSecondsFromLocal

      public abstract long getEpochSecondsFromLocal(long dateValue, long timeNanos)
      Calculates the epoch seconds from local date and time.
      Parameters:
      dateValue - date value
      timeNanos - nanoseconds since midnight
      Returns:
      the epoch seconds value
    • getId

      public abstract String getId()
      Returns the ID of the time zone.
      Returns:
      the ID of the time zone
    • getShortId

      public abstract String getShortId(long epochSeconds)
      Get the standard time name or daylight saving time name of the time zone.
      Parameters:
      epochSeconds - seconds since EPOCH
      Returns:
      the standard time name or daylight saving time name of the time zone
    • hasFixedOffset

      public boolean hasFixedOffset()
      Returns whether this is a simple time zone provider with a fixed offset from UTC.
      Returns:
      whether this is a simple time zone provider with a fixed offset from UTC