Package org.h2.util
Class TimeZoneProvider.WithTimeZone
- java.lang.Object
-
- org.h2.util.TimeZoneProvider
-
- org.h2.util.TimeZoneProvider.WithTimeZone
-
- Enclosing class:
- TimeZoneProvider
static final class TimeZoneProvider.WithTimeZone extends TimeZoneProvider
Time zone provider with time zone.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.h2.util.TimeZoneProvider
TimeZoneProvider.WithTimeZone
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static longSECONDS_PER_PERIODNumber of seconds in 400 years.(package private) static longSECONDS_PER_YEARNumber of seconds per year.private static java.time.format.DateTimeFormatterTIME_ZONE_FORMATTERprivate java.time.ZoneIdzoneId-
Fields inherited from class org.h2.util.TimeZoneProvider
CACHE, UTC
-
-
Constructor Summary
Constructors Constructor Description WithTimeZone(java.time.ZoneId timeZone)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)longgetEpochSecondsFromLocal(long dateValue, long timeNanos)Calculates the epoch seconds from local date and time.java.lang.StringgetId()Returns the ID of the time zone.java.lang.StringgetShortId(long epochSeconds)Get the standard time name or daylight saving time name of the time zone.intgetTimeZoneOffsetLocal(long dateValue, long timeNanos)Calculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.intgetTimeZoneOffsetUTC(long epochSeconds)Calculates the time zone offset in seconds for the specified EPOCH seconds.inthashCode()java.lang.StringtoString()private static intyearForCalendar(int year)Returns a year within the range -999,999,999..999,999,999 for the given year.-
Methods inherited from class org.h2.util.TimeZoneProvider
getDefault, hasFixedOffset, ofId, ofOffset
-
-
-
-
Field Detail
-
SECONDS_PER_PERIOD
static final long SECONDS_PER_PERIOD
Number of seconds in 400 years.- See Also:
- Constant Field Values
-
SECONDS_PER_YEAR
static final long SECONDS_PER_YEAR
Number of seconds per year.- See Also:
- Constant Field Values
-
TIME_ZONE_FORMATTER
private static volatile java.time.format.DateTimeFormatter TIME_ZONE_FORMATTER
-
zoneId
private final java.time.ZoneId zoneId
-
-
Method Detail
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getTimeZoneOffsetUTC
public int getTimeZoneOffsetUTC(long epochSeconds)
Description copied from class:TimeZoneProviderCalculates the time zone offset in seconds for the specified EPOCH seconds.- Specified by:
getTimeZoneOffsetUTCin classTimeZoneProvider- Parameters:
epochSeconds- seconds since EPOCH- Returns:
- time zone offset in minutes
-
getTimeZoneOffsetLocal
public int getTimeZoneOffsetLocal(long dateValue, long timeNanos)Description copied from class:TimeZoneProviderCalculates the time zone offset in seconds for the specified date value and nanoseconds since midnight in local time.- Specified by:
getTimeZoneOffsetLocalin classTimeZoneProvider- Parameters:
dateValue- date valuetimeNanos- nanoseconds since midnight- Returns:
- time zone offset in minutes
-
getEpochSecondsFromLocal
public long getEpochSecondsFromLocal(long dateValue, long timeNanos)Description copied from class:TimeZoneProviderCalculates the epoch seconds from local date and time.- Specified by:
getEpochSecondsFromLocalin classTimeZoneProvider- Parameters:
dateValue- date valuetimeNanos- nanoseconds since midnight- Returns:
- the epoch seconds value
-
getId
public java.lang.String getId()
Description copied from class:TimeZoneProviderReturns the ID of the time zone.- Specified by:
getIdin classTimeZoneProvider- Returns:
- the ID of the time zone
-
getShortId
public java.lang.String getShortId(long epochSeconds)
Description copied from class:TimeZoneProviderGet the standard time name or daylight saving time name of the time zone.- Specified by:
getShortIdin classTimeZoneProvider- Parameters:
epochSeconds- seconds since EPOCH- Returns:
- the standard time name or daylight saving time name of the time zone
-
yearForCalendar
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- the year- Returns:
- the specified year or the replacement year within the range
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-