Package org.zkoss.util
Class TimeZones
java.lang.Object
org.zkoss.util.TimeZones
Utilities to access time-zone.
- Author:
- tomyeh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final TimeZoneReturns the current time zone; never null.static final TimeZoneReturns the time zone defined bysetThreadLocal(java.util.TimeZone).static final TimeZonegetTimeZone(int ofsmins) Returns the time by specifying the offset in minutes.static final TimeZonesetThreadLocal(TimeZone timezone) Sets the time-zone for the current thread only.
-
Constructor Details
-
TimeZones
public TimeZones()
-
-
Method Details
-
getCurrent
Returns the current time zone; never null. This is the time zone that every other objects shall use, unless they have special consideration.Default: If
setThreadLocal(java.util.TimeZone)was called with non-null, the value is returned. Otherwise, TimeZone.getDefault() is returned, -
setThreadLocal
Sets the time-zone for the current thread only.Each thread could have an independent time zone, called the thread time zone.
When Invoking this method under a thread that serves requests, remember to clean up the setting upon completing each request.
TimeZone old = TimeZones.setThreadLocal(newValue); try { ... } finally { TimeZones.setThreadLocal(old); }- Parameters:
timezone- the thread time zone; null to denote no thread time zone (and the system's timezone will be used instead)- Returns:
- the previous thread time zone, or null if no previous time zone
-
getThreadLocal
Returns the time zone defined bysetThreadLocal(java.util.TimeZone).- Since:
- 3.0.0
- See Also:
-
getTimeZone
Returns the time by specifying the offset in minutes.For example, the following are equivalent.
TimeZone.getTimeZone("GMT+8"); TimeZones.getTimeZone(480);- Parameters:
ofsmins- the offset in minutes.
-