Class TimeZone


  • public class TimeZone
    extends Object
    Represents an instance of an valid time zone, wrapping a TimeZone. Call getInstance(String) to get a specific TimeZone object.

    The list of acceptable time zones is loaded once from a properties file, and trying to retrieve a time zone not in this list will return the application's default time zone.

    TODO CONFDEV-27850: should be using a CacheLoader for timeZonesByID to avoid race conditions on TimeZone construction.

    • Method Detail

      • getInstance

        public static TimeZone getInstance​(String timeZoneID)
        Returns the flyweight TimeZone for the given ID, which is the same instance used for this time zone throughout the system.
        Parameters:
        timeZoneID - a valid time zone ID as specified by TimeZone
        Returns:
        the TimeZone specified by the time zone ID, or the default time zone if timeZoneID is null or not in the list of time zones returned by getSortedTimeZones().
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getDisplayOffset

        public String getDisplayOffset()
        Returns:
        the raw offset in a printable format, e.g. +0800, -1230
      • getDefault

        @Deprecated
        public static TimeZone getDefault()
        Deprecated.
        since 5.7. Use TimeZoneManager.getDefaultTimeZone()} instead.
        This method should no longer be used. The notion of a "default timezone" is now specific to the current tenant, rather than a system level JDK concern.
        Returns:
        the tenant's default timezone, retrieved from TimeZoneManager.getDefaultTimeZone()}
        See Also:
        TimeZoneManager.getDefaultTimeZone()
      • getSortedTimeZones

        public static List<TimeZone> getSortedTimeZones()
        Returns:
        the list of available time zones sorted by offset from GMT (west to east), then by alphabetical order of time zone ID.
      • getWrappedTimeZone

        public TimeZone getWrappedTimeZone()
        Returns:
        the underlying TimeZone which is wrapped by this implementation.