Package com.atlassian.confluence.core
Class TimeZone
- java.lang.Object
-
- com.atlassian.confluence.core.TimeZone
-
public class TimeZone extends Object
Represents an instance of an valid time zone, wrapping aTimeZone. CallgetInstance(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 Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object o)static TimeZonegetDefault()Deprecated.since 5.7.StringgetDisplayOffset()StringgetID()static TimeZonegetInstance(String timeZoneID)Returns the flyweightTimeZonefor the given ID, which is the same instance used for this time zone throughout the system.static TimeZonegetInstance(TimeZone timeZone)StringgetMessageKey()static List<TimeZone>getSortedTimeZones()TimeZonegetWrappedTimeZone()inthashCode()StringtoString()
-
-
-
Method Detail
-
getInstance
public static TimeZone getInstance(String timeZoneID)
Returns the flyweightTimeZonefor 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 byTimeZone- Returns:
- the
TimeZonespecified by the time zone ID, or the default time zone if timeZoneID is null or not in the list of time zones returned bygetSortedTimeZones().
-
getID
public String getID()
- Returns:
- the time zone identifier as returned by
TimeZone.getID().
-
getMessageKey
public String getMessageKey()
- Returns:
- a message key which can be used with
ConfluenceActionSupport.getText(String)to display the localised name of the time zone.
-
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. UseTimeZoneManager.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.
-
-