Class TimeZones


  • public class TimeZones
    extends java.lang.Object
    Helps dealing with TimeZones.
    Since:
    3.7
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.TimeZone GMT
      The GMT time zone.
      static java.lang.String GMT_ID
      A public version of TimeZone's package private GMT_ID field.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.TimeZone getTimeZone​(java.lang.String id)
      Delegates to TimeZone.getTimeZone(String), on Java 25 and up, maps an ID if it's a key in ZoneId.SHORT_IDS.
      static java.util.TimeZone toTimeZone​(java.util.TimeZone timeZone)
      Returns the given TimeZone if non-null, otherwise TimeZone.getDefault().
      • Methods inherited from class java.lang.Object

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

      • GMT_ID

        public static final java.lang.String GMT_ID
        A public version of TimeZone's package private GMT_ID field.
        See Also:
        Constant Field Values
      • GMT

        public static final java.util.TimeZone GMT
        The GMT time zone.
        Since:
        3.13.0
    • Method Detail

      • getTimeZone

        public static java.util.TimeZone getTimeZone​(java.lang.String id)
        Delegates to TimeZone.getTimeZone(String), on Java 25 and up, maps an ID if it's a key in ZoneId.SHORT_IDS.

        On Java 25, calling TimeZone.getTimeZone(String) with an ID in ZoneId.SHORT_IDS writes a message to System.err in the form:

         WARNING: Use of the three-letter time zone ID "the-short-id" is deprecated and it will be removed in a future release
         

        You can disable mapping from ZoneId.SHORT_IDS by setting the system property "TimeZones.mapShortIDs=false".

        Parameters:
        id - Same as TimeZone.getTimeZone(String).
        Returns:
        Same as TimeZone.getTimeZone(String).
        Since:
        3.20.0
      • toTimeZone

        public static java.util.TimeZone toTimeZone​(java.util.TimeZone timeZone)
        Returns the given TimeZone if non-null, otherwise TimeZone.getDefault().
        Parameters:
        timeZone - a locale or null.
        Returns:
        the given locale if non-null, otherwise TimeZone.getDefault().
        Since:
        3.13.0