GeezerVison is showing docs.oracle.com — TimeZone (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.util
Class TimeZone
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static int |
LONG |
A style specifier for getDisplayName() indicating
a long name, such as "Pacific Standard Time."
|
static int |
SHORT |
A style specifier for getDisplayName() indicating
a short name, such as "PST."
|
-
Constructor Summary
Constructors
| Constructor |
Description |
TimeZone() |
Sole constructor.
|
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
| Modifier and Type |
Method |
Description |
Object |
clone() |
Creates a copy of this TimeZone.
|
static String[] |
getAvailableIDs() |
Gets all the available IDs supported.
|
static String[] |
getAvailableIDs(int rawOffset) |
Gets the available IDs according to the given time zone offset in milliseconds.
|
static TimeZone |
getDefault() |
Gets the default TimeZone of the Java virtual machine.
|
String |
getDisplayName() |
Returns a long standard time name of this TimeZone suitable for
presentation to the user in the default locale.
|
String |
getDisplayName(boolean daylight,
int style) |
Returns a name in the specified style of this TimeZone
suitable for presentation to the user in the default locale.
|
String |
getDisplayName(boolean daylight,
int style,
Locale locale) |
Returns a name in the specified style of this TimeZone
suitable for presentation to the user in the specified locale.
|
String |
getDisplayName(Locale locale) |
Returns a long standard time name of this TimeZone suitable for
presentation to the user in the specified locale.
|
int |
getDSTSavings() |
Returns the amount of time to be added to local standard time
to get local wall clock time.
|
String |
getID() |
Gets the ID of this time zone.
|
abstract int |
getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int milliseconds) |
Gets the time zone offset, for current date, modified in case of
daylight savings.
|
int |
getOffset(long date) |
Returns the offset of this time zone from UTC at the specified
date.
|
abstract int |
getRawOffset() |
Returns the amount of time in milliseconds to add to UTC to get
standard time in this time zone.
|
static TimeZone |
getTimeZone(String ID) |
Gets the TimeZone for the given ID.
|
static TimeZone |
getTimeZone(ZoneId zoneId) |
Gets the TimeZone for the given zoneId.
|
boolean |
hasSameRules(TimeZone other) |
Returns true if this zone has the same rule and offset as another zone.
|
abstract boolean |
inDaylightTime(Date date) |
Queries if the given date is in Daylight Saving Time in
this time zone.
|
boolean |
observesDaylightTime() |
Returns true if this TimeZone is currently in
Daylight Saving Time, or if a transition from Standard Time to
Daylight Saving Time occurs at any future time.
|
static void |
setDefault(TimeZone zone) |
Sets the TimeZone that is returned by the getDefault
method.
|
void |
setID(String ID) |
Sets the time zone ID.
|
abstract void |
setRawOffset(int offsetMillis) |
Sets the base time zone offset to GMT.
|
ZoneId |
toZoneId() |
Converts this TimeZone object to a ZoneId.
|
abstract boolean |
useDaylightTime() |
Queries if this TimeZone uses Daylight Saving Time.
|
-
-
Field Detail
-
SHORT
public static final int SHORT
A style specifier for getDisplayName() indicating
a short name, such as "PST."
- Since:
- 1.2
- See Also:
LONG,
Constant Field Values
-
LONG
public static final int LONG
A style specifier for getDisplayName() indicating
a long name, such as "Pacific Standard Time."
- Since:
- 1.2
- See Also:
SHORT,
Constant Field Values
-
Method Detail
-
getOffset
public abstract int getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int milliseconds)
Gets the time zone offset, for current date, modified in case of
daylight savings. This is the offset to add to UTC to get local time.
This method returns a historically correct offset if an
underlying TimeZone implementation subclass
supports historical Daylight Saving Time schedule and GMT
offset changes.
- Parameters:
era - the era of the given date.
year - the year in the given date.
month - the month in the given date.
Month is 0-based. e.g., 0 for January.
day - the day-in-month of the given date.
dayOfWeek - the day-of-week of the given date.
milliseconds - the milliseconds in day in standard
local time.
- Returns:
- the offset in milliseconds to add to GMT to get local time.
- See Also:
Calendar.ZONE_OFFSET,
Calendar.DST_OFFSET
-
setDefault
public static void setDefault(TimeZone zone)
Sets the TimeZone that is returned by the getDefault
method. zone is cached. If zone is null, the cached
default TimeZone is cleared. This method doesn't change the value
of the user.timezone property.
- Parameters:
zone - the new default TimeZone, or null
- Throws:
SecurityException - if the security manager's checkPermission
denies PropertyPermission("user.timezone",
"write")
- See Also:
getDefault(),
PropertyPermission
-
hasSameRules
public boolean hasSameRules(TimeZone other)
Returns true if this zone has the same rule and offset as another zone.
That is, if this zone differs only in ID, if at all. Returns false
if the other zone is null.
- Parameters:
other - the TimeZone object to be compared with
- Returns:
- true if the other zone is not null and is the same as this one,
with the possible exception of the ID
- Since:
- 1.2
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|