GeezerVison is showing docs.oracle.com — ZoneOffset (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.time
Class ZoneOffset
-
- All Implemented Interfaces:
- Serializable, Comparable<ZoneOffset>, TemporalAccessor, TemporalAdjuster
public final class ZoneOffset
extends ZoneId
implements TemporalAccessor, TemporalAdjuster, Comparable<ZoneOffset>, Serializable
A time-zone offset from Greenwich/UTC, such as +02:00.
A time-zone offset is the amount of time that a time-zone differs from Greenwich/UTC.
This is usually a fixed number of hours and minutes.
Different parts of the world have different time-zone offsets.
The rules for how offsets vary by place and time of year are captured in the
ZoneId class.
For example, Paris is one hour ahead of Greenwich/UTC in winter and two hours
ahead in summer. The ZoneId instance for Paris will reference two
ZoneOffset instances - a +01:00 instance for winter,
and a +02:00 instance for summer.
In 2008, time-zone offsets around the world extended from -12:00 to +14:00.
To prevent any problems with that range being extended, yet still provide
validation, the range of offsets is restricted to -18:00 to 18:00 inclusive.
This class is designed for use with the ISO calendar system.
The fields of hours, minutes and seconds make assumptions that are valid for the
standard ISO definitions of those fields. This class may be used with other
calendar systems providing the definition of the time fields matches those
of the ISO calendar system.
Instances of ZoneOffset must be compared using equals(java.lang.Object).
Implementations may choose to cache certain common offsets, however
applications must not rely on such caching.
This is a value-based
class; use of identity-sensitive operations (including reference equality
(==), identity hash code, or synchronization) on instances of
ZoneOffset may have unpredictable results and should be avoided.
The equals method should be used for comparisons.
- Implementation Requirements:
- This class is immutable and thread-safe.
- Since:
- 1.8
- See Also:
- Serialized Form
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static ZoneOffset |
MAX |
Constant for the maximum supported offset.
|
static ZoneOffset |
MIN |
Constant for the maximum supported offset.
|
static ZoneOffset |
UTC |
The time-zone offset for UTC, with an ID of 'Z'.
|
-
-
Method Detail
-
getId
public String getId()
Gets the normalized zone offset ID.
The ID is minor variation to the standard ISO-8601 formatted string
for the offset. There are three formats:
Z - for UTC (ISO-8601)
+hh:mm or -hh:mm - if the seconds are zero (ISO-8601)
+hh:mm:ss or -hh:mm:ss - if the seconds are non-zero (not ISO-8601)
- Specified by:
getId in class ZoneId
- Returns:
- the zone offset ID, not null
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.
|