← 返回首页
ZoneOffset (Java SE 26 & JDK 26)
JavaScript is disabled on your browser.
Contents  
  1. Description
  2. Field Summary
  3. Method Summary
    1. Methods declared in class ZoneId
    2. Methods declared in class Object
  4. Field Details
    1. UTC
    2. MIN
    3. MAX
  5. Method Details
    1. of(String)
    2. ofHours(int)
    3. ofHoursMinutes(int, int)
    4. ofHoursMinutesSeconds(int, int, int)
    5. from(TemporalAccessor)
    6. ofTotalSeconds(int)
    7. getTotalSeconds()
    8. getId()
    9. getRules()
    10. isSupported(TemporalField)
    11. range(TemporalField)
    12. get(TemporalField)
    13. getLong(TemporalField)
    14. query(TemporalQuery)
    15. adjustInto(Temporal)
    16. compareTo(ZoneOffset)
    17. equals(Object)
    18. hashCode()
    19. toString()
Hide sidebar  Show sidebar

Class ZoneOffset

java.lang.Object
java.time.ZoneId
java.time.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(Object). Implementations may choose to cache certain common offsets, however applications must not rely on such caching.

This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail. The equals method should be used for comparisons.

Implementation Requirements: This class is immutable and thread-safe. Since: 1.8 See Also:

Scripting on this page tracks web page traffic, but does not change the content in any way.