Top Description Inners Fields Constructors Methods
org.h2.util

public abstract Class TimeZoneProvider

extends Object
Class Inheritance
Known Direct Subclasses
org.h2.util.TimeZoneProvider.Simple, org.h2.util.TimeZoneProvider.WithTimeZone
Imports
java.time.Instant, .LocalDateTime, .ZoneId, .ZoneOffset, .ZonedDateTime, java.time.format.DateTimeFormatter, java.time.zone.ZoneRules, java.util.Locale

Provides access to time zone API.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TimeZoneProvider.Simple

Time zone provider with offset.

pack-priv static class
TimeZoneProvider.WithTimeZone

Time zone provider with time zone.

Field Summary

Modifier and TypeField and Description
public static TimeZoneProvider[]
CACHE

A small cache for timezone providers.

private static final int
CACHE_SIZE

The number of cache elements (needs to be a power of 2).

public static final TimeZoneProvider
UTC

The UTC time zone provider.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static TimeZoneProvider

Returns:

the time zone provider for the system default time zone
getDefault
()

Returns the time zone provider for the system default time zone.

public abstract long

Returns:

the epoch seconds value
getEpochSecondsFromLocal
(long
date value
dateValue
,
long
nanoseconds since midnight
timeNanos
)

Calculates the epoch seconds from local date and time.

public abstract String

Returns:

the ID of the time zone
getId
()

Returns the ID of the time zone.

public abstract String

Returns:

the standard time name or daylight saving time name of the time zone
getShortId
(long
seconds since EPOCH
epochSeconds
)

Get the standard time name or daylight saving time name of the time zone.

public abstract int

Returns:

time zone offset in minutes
getTimeZoneOffsetLocal
(long
date value
dateValue
,
long
nanoseconds since midnight
timeNanos
)

Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.

public abstract int

Returns:

time zone offset in minutes
getTimeZoneOffsetUTC
(long
seconds since EPOCH
epochSeconds
)

Calculates the time zone offset in seconds for the specified EPOCH seconds.

public boolean

Returns:

whether this is a simple time zone provider with a fixed offset from UTC
hasFixedOffset
()

Returns whether this is a simple time zone provider with a fixed offset from UTC.

public static TimeZoneProvider

Returns:

the time zone provider with the specified name
ofId
(String
the ID of the time zone
id
)

Returns the time zone provider with the specified name.

public static TimeZoneProvider

Returns:

the time zone provider with the specified offset
ofOffset
(int
UTC offset in seconds
offset
)

Returns the time zone provider with the specified offset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHEback to summary
public static TimeZoneProvider[] CACHE

A small cache for timezone providers.

CACHE_SIZEback to summary
private static final int CACHE_SIZE

The number of cache elements (needs to be a power of 2).

UTCback to summary
public static final TimeZoneProvider UTC

The UTC time zone provider.

Constructor Detail

TimeZoneProviderback to summary
public TimeZoneProvider()

Method Detail

getDefaultback to summary
public static TimeZoneProvider getDefault()

Returns the time zone provider for the system default time zone.

Returns:TimeZoneProvider

the time zone provider for the system default time zone

getEpochSecondsFromLocalback to summary
public abstract long getEpochSecondsFromLocal(long dateValue, long timeNanos)

Calculates the epoch seconds from local date and time.

Parameters
dateValue:long

date value

timeNanos:long

nanoseconds since midnight

Returns:long

the epoch seconds value

getIdback to summary
public abstract String getId()

Returns the ID of the time zone.

Returns:String

the ID of the time zone

getShortIdback to summary
public abstract String getShortId(long epochSeconds)

Get the standard time name or daylight saving time name of the time zone.

Parameters
epochSeconds:long

seconds since EPOCH

Returns:String

the standard time name or daylight saving time name of the time zone

getTimeZoneOffsetLocalback to summary
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:long

date value

timeNanos:long

nanoseconds since midnight

Returns:int

time zone offset in minutes

getTimeZoneOffsetUTCback to summary
public abstract int getTimeZoneOffsetUTC(long epochSeconds)

Calculates the time zone offset in seconds for the specified EPOCH seconds.

Parameters
epochSeconds:long

seconds since EPOCH

Returns:int

time zone offset in minutes

hasFixedOffsetback to summary
public boolean hasFixedOffset()

Returns whether this is a simple time zone provider with a fixed offset from UTC.

Returns:boolean

whether this is a simple time zone provider with a fixed offset from UTC

ofIdback to summary
public static TimeZoneProvider ofId(String id) throws RuntimeException

Returns the time zone provider with the specified name.

Parameters
id:String

the ID of the time zone

Returns:TimeZoneProvider

the time zone provider with the specified name

Exceptions
RuntimeException:
if time zone with specified ID isn't known
ofOffsetback to summary
public static TimeZoneProvider ofOffset(int offset)

Returns the time zone provider with the specified offset.

Parameters
offset:int

UTC offset in seconds

Returns:TimeZoneProvider

the time zone provider with the specified offset

org.h2.util back to summary

private final Class TimeZoneProvider.Simple

extends TimeZoneProvider
Class Inheritance

Time zone provider with offset.

Field Summary

Modifier and TypeField and Description
private volatile String
private final int
Inherited from org.h2.util.TimeZoneProvider:
CACHEUTC

Constructor Summary

AccessConstructor and Description
pack-priv
Simple(int offset)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public long
getEpochSecondsFromLocal(long
date value
dateValue
,
long
nanoseconds since midnight
timeNanos
)

Implements abstract org.h2.util.TimeZoneProvider.getEpochSecondsFromLocal.

Calculates the epoch seconds from local date and time.

public String
getId()

Implements abstract org.h2.util.TimeZoneProvider.getId.

Returns the ID of the time zone.

public String
getShortId(long
seconds since EPOCH
epochSeconds
)

Implements abstract org.h2.util.TimeZoneProvider.getShortId.

Get the standard time name or daylight saving time name of the time zone.

public int
getTimeZoneOffsetLocal(long
date value
dateValue
,
long
nanoseconds since midnight
timeNanos
)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetLocal.

Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.

public int
getTimeZoneOffsetUTC(long
seconds since EPOCH
epochSeconds
)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetUTC.

Calculates the time zone offset in seconds for the specified EPOCH seconds.

public boolean
hasFixedOffset()

Overrides org.h2.util.TimeZoneProvider.hasFixedOffset.

Returns whether this is a simple time zone provider with a fixed offset from UTC.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.h2.util.TimeZoneProvider:
getDefaultofIdofOffset

Field Detail

idback to summary
private volatile String id
offsetback to summary
private final int offset

Constructor Detail

Simpleback to summary
pack-priv Simple(int offset)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getEpochSecondsFromLocalback to summary
public long getEpochSecondsFromLocal(long dateValue, long timeNanos)

Implements abstract org.h2.util.TimeZoneProvider.getEpochSecondsFromLocal.

Doc from org.h2.util.TimeZoneProvider.getEpochSecondsFromLocal.

Calculates the epoch seconds from local date and time.

Parameters
dateValue:long

date value

timeNanos:long

nanoseconds since midnight

Returns:long

the epoch seconds value

Annotations
@Override
getIdback to summary
public String getId()

Implements abstract org.h2.util.TimeZoneProvider.getId.

Doc from org.h2.util.TimeZoneProvider.getId.

Returns the ID of the time zone.

Returns:String

the ID of the time zone

Annotations
@Override
getShortIdback to summary
public String getShortId(long epochSeconds)

Implements abstract org.h2.util.TimeZoneProvider.getShortId.

Doc from org.h2.util.TimeZoneProvider.getShortId.

Get the standard time name or daylight saving time name of the time zone.

Parameters
epochSeconds:long

seconds since EPOCH

Returns:String

the standard time name or daylight saving time name of the time zone

Annotations
@Override
getTimeZoneOffsetLocalback to summary
public int getTimeZoneOffsetLocal(long dateValue, long timeNanos)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetLocal.

Doc from org.h2.util.TimeZoneProvider.getTimeZoneOffsetLocal.

Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.

Parameters
dateValue:long

date value

timeNanos:long

nanoseconds since midnight

Returns:int

time zone offset in minutes

Annotations
@Override
getTimeZoneOffsetUTCback to summary
public int getTimeZoneOffsetUTC(long epochSeconds)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetUTC.

Doc from org.h2.util.TimeZoneProvider.getTimeZoneOffsetUTC.

Calculates the time zone offset in seconds for the specified EPOCH seconds.

Parameters
epochSeconds:long

seconds since EPOCH

Returns:int

time zone offset in minutes

Annotations
@Override
hasFixedOffsetback to summary
public boolean hasFixedOffset()

Overrides org.h2.util.TimeZoneProvider.hasFixedOffset.

Doc from org.h2.util.TimeZoneProvider.hasFixedOffset.

Returns whether this is a simple time zone provider with a fixed offset from UTC.

Returns:boolean

whether this is a simple time zone provider with a fixed offset from UTC

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.h2.util back to summary

pack-priv final Class TimeZoneProvider.WithTimeZone

extends TimeZoneProvider
Class Inheritance

Time zone provider with time zone.

Field Summary

Modifier and TypeField and Description
pack-priv static final long
SECONDS_PER_PERIOD

Number of seconds in 400 years.

pack-priv static final long
SECONDS_PER_YEAR

Number of seconds per year.

private static volatile DateTimeFormatter
private final ZoneId
Inherited from org.h2.util.TimeZoneProvider:
CACHEUTC

Constructor Summary

AccessConstructor and Description
pack-priv
WithTimeZone(ZoneId timeZone)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public long
getEpochSecondsFromLocal(long
date value
dateValue
,
long
nanoseconds since midnight
timeNanos
)

Implements abstract org.h2.util.TimeZoneProvider.getEpochSecondsFromLocal.

Calculates the epoch seconds from local date and time.

public String
getId()

Implements abstract org.h2.util.TimeZoneProvider.getId.

Returns the ID of the time zone.

public String
getShortId(long
seconds since EPOCH
epochSeconds
)

Implements abstract org.h2.util.TimeZoneProvider.getShortId.

Get the standard time name or daylight saving time name of the time zone.

public int
getTimeZoneOffsetLocal(long
date value
dateValue
,
long
nanoseconds since midnight
timeNanos
)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetLocal.

Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.

public int
getTimeZoneOffsetUTC(long
seconds since EPOCH
epochSeconds
)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetUTC.

Calculates the time zone offset in seconds for the specified EPOCH seconds.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static int

Returns:

the specified year or the replacement year within the range
yearForCalendar
(int
the year
year
)

Returns a year within the range -999,999,999..999,999,999 for the given year.

Inherited from org.h2.util.TimeZoneProvider:
getDefaulthasFixedOffsetofIdofOffset

Field Detail

SECONDS_PER_PERIODback to summary
pack-priv static final long SECONDS_PER_PERIOD

Number of seconds in 400 years.

SECONDS_PER_YEARback to summary
pack-priv static final long SECONDS_PER_YEAR

Number of seconds per year.

TIME_ZONE_FORMATTERback to summary
private static volatile DateTimeFormatter TIME_ZONE_FORMATTER
zoneIdback to summary
private final ZoneId zoneId

Constructor Detail

WithTimeZoneback to summary
pack-priv WithTimeZone(ZoneId timeZone)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getEpochSecondsFromLocalback to summary
public long getEpochSecondsFromLocal(long dateValue, long timeNanos)

Implements abstract org.h2.util.TimeZoneProvider.getEpochSecondsFromLocal.

Doc from org.h2.util.TimeZoneProvider.getEpochSecondsFromLocal.

Calculates the epoch seconds from local date and time.

Parameters
dateValue:long

date value

timeNanos:long

nanoseconds since midnight

Returns:long

the epoch seconds value

Annotations
@Override
getIdback to summary
public String getId()

Implements abstract org.h2.util.TimeZoneProvider.getId.

Doc from org.h2.util.TimeZoneProvider.getId.

Returns the ID of the time zone.

Returns:String

the ID of the time zone

Annotations
@Override
getShortIdback to summary
public String getShortId(long epochSeconds)

Implements abstract org.h2.util.TimeZoneProvider.getShortId.

Doc from org.h2.util.TimeZoneProvider.getShortId.

Get the standard time name or daylight saving time name of the time zone.

Parameters
epochSeconds:long

seconds since EPOCH

Returns:String

the standard time name or daylight saving time name of the time zone

Annotations
@Override
getTimeZoneOffsetLocalback to summary
public int getTimeZoneOffsetLocal(long dateValue, long timeNanos)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetLocal.

Doc from org.h2.util.TimeZoneProvider.getTimeZoneOffsetLocal.

Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.

Parameters
dateValue:long

date value

timeNanos:long

nanoseconds since midnight

Returns:int

time zone offset in minutes

Annotations
@Override
getTimeZoneOffsetUTCback to summary
public int getTimeZoneOffsetUTC(long epochSeconds)

Implements abstract org.h2.util.TimeZoneProvider.getTimeZoneOffsetUTC.

Doc from org.h2.util.TimeZoneProvider.getTimeZoneOffsetUTC.

Calculates the time zone offset in seconds for the specified EPOCH seconds.

Parameters
epochSeconds:long

seconds since EPOCH

Returns:int

time zone offset in minutes

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
yearForCalendarback to summary
private static int yearForCalendar(int year)

Returns a year within the range -999,999,999..999,999,999 for the given year. Too large and too small years are replaced with years within the range using the 400 years period of the Gregorian calendar. Because we need them only to calculate a time zone offset, it's safe to normalize them to such range.

Parameters
year:int

the year

Returns:int

the specified year or the replacement year within the range