Top Description Fields Constructors Methods
org.apache.commons.lang3.time

public Class TimeZones

extends Object
Class Inheritance
Imports
java.time.ZoneId, java.util.TimeZone, org.apache.commons.lang3.JavaVersion, .ObjectUtils, .SystemProperties, .SystemUtils

Helps dealing with java.util.TimeZones.
Since
3.7

Field Summary

Modifier and TypeField and Description
public static final TimeZone
GMT

The GMT time zone.

public static final String
GMT_ID

A public version of java.util.TimeZone's package private GMT_ID field.

private static final boolean

Constructor Summary

AccessConstructor and Description
private
TimeZones()

Do not instantiate.

Method Summary

Modifier and TypeMethod and Description
public static TimeZone
getTimeZone(final String id)

Delegates to TimeZone#getTimeZone(String), on Java 25 and up, maps an ID if it's a key in ZoneId#SHORT_IDS.

private static boolean
public static TimeZone

Returns:

the given locale if non-null, otherwise TimeZone#getDefault().
toTimeZone
(final TimeZone
a locale or null.
timeZone
)

Returns the given TimeZone if non-null, otherwise TimeZone#getDefault().

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

GMTback to summary
public static final TimeZone GMT

The GMT time zone.

Since
3.13.0
GMT_IDback to summary
public static final String GMT_ID

A public version of java.util.TimeZone's package private GMT_ID field.

JAVA_25back to summary
private static final boolean JAVA_25

Constructor Detail

TimeZonesback to summary
private TimeZones()

Do not instantiate.

Method Detail

getTimeZoneback to summary
public static TimeZone getTimeZone(final 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:String

Same as TimeZone#getTimeZone(String).

Returns:TimeZone

Same as TimeZone#getTimeZone(String).

Since
3.20.0
mapShortIDsback to summary
private static boolean mapShortIDs()
toTimeZoneback to summary
public static TimeZone toTimeZone(final TimeZone timeZone)

Returns the given TimeZone if non-null, otherwise TimeZone#getDefault().

Parameters
timeZone:TimeZone

a locale or null.

Returns:TimeZone

the given locale if non-null, otherwise TimeZone#getDefault().

Since
3.13.0