# Class TimeZones

java.lang.Object
org.apache.commons.lang3.time.TimeZones

public class TimeZones extends Object
Helps dealing with `TimeZone`s.

Since:
  3.7

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final TimeZone`
  `GMT`
  The GMT time zone.
  `static final String`
  `GMT_ID`
  A public version of `TimeZone`'s package private `GMT_ID` field.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static TimeZone`
  `getTimeZone(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 TimeZone`
  `toTimeZone(TimeZone timeZone)`
  Returns the given TimeZone if non-`null`, otherwise `TimeZone.getDefault()`.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### GMT_ID

    public static final String GMT_ID
    A public version of `TimeZone`'s package private `GMT_ID` field.
    See Also:
      - Constant Field Values

  - ### GMT

    public static final TimeZone GMT
    The GMT time zone.
    Since:
      3.13.0

- ## Method Details

  - ### getTimeZone

    public static TimeZone getTimeZone(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 TimeZone toTimeZone(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