public class TimeZones
extends java.lang.Object
Constructor and Description |
---|
TimeZones() |
Modifier and Type | Method and Description |
---|---|
static java.util.TimeZone |
getCurrent()
Returns the current time zone; never null.
|
static java.util.TimeZone |
getThreadLocal()
Returns the time zone defined by
setThreadLocal(java.util.TimeZone) . |
static java.util.TimeZone |
getTimeZone(int ofsmins)
Returns the time by specifying the offset in minutes.
|
static java.util.TimeZone |
setThreadLocal(java.util.TimeZone timezone)
Sets the time-zone for the current thread only.
|
public static final java.util.TimeZone getCurrent()
Default: If setThreadLocal(java.util.TimeZone)
was called with non-null,
the value is returned. Otherwise, TimeZone.getDefault() is returned,
public static final java.util.TimeZone setThreadLocal(java.util.TimeZone timezone)
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);
}
timezone
- the thread time zone; null to denote no thread time zone
(and the system's timezone will be used instead)public static final java.util.TimeZone getThreadLocal()
setThreadLocal(java.util.TimeZone)
.getCurrent()
public static final java.util.TimeZone getTimeZone(int ofsmins)
For example, the following are equivalent.
TimeZone.getTimeZone("GMT+8");
TimeZones.getTimeZone(480);
ofsmins
- the offset in minutes.Copyright © 2005-2011 Potix Corporation. All Rights Reserved.