java.time.ZoneOffset类

简介

java.time.ZoneOffset 类表示格林威治/UTC的时区偏移量,例如+02:00.

类声明

以下是 java.time.ZoneOffset class :

public final class ZoneOffset
   extends ZoneId
      implements TemporalAccessor, TemporalAdjuster, Comparable<ZoneOffset>, Serializable

字段

以下是Java.time.ZoneOffset类的字段:

  • static ZoneOffset MAX : 最大支持偏移量的常量.

  • static ZoneOffset MIN : 最小支持偏移量的常量.

  • static ZoneOffset UTC: UTC的时区偏移量,ID为"Z"。

类方法

Sr.No.Method & Description
1Temporal adjustInto(Temporal temporal)

Adjusts the specified temporal object to have the same offset as this object.

2int compareTo(ZoneOffset other)

Compares this offset to another offset in descending order.

3boolean equals(Object obj)

Checks if this offset is equal to another offset.

4static ZoneOffset from(TemporalAccessor temporal)

Obtains an instance of ZoneOffset from a temporal object.

5int get(TemporalField field)

Gets the value of the specified field from this offset as an int.

6String getId()

Gets the normalized zone offset ID.

7long getLong(TemporalField field)

Gets the value of the specified field from this offset as a long.

8ZoneRules getRules()

Gets the associated time-zone rules.

9int getTotalSeconds()

Gets the total zone offset in seconds.

10int hashCode()

A hash code for this offset.

11boolean isSupported(TemporalField field)

Checks if the specified field is supported.

12static ZoneOffset of(String offsetId)

Obtains an instance of ZoneOffset using the ID.

13static ZoneOffset ofHours(int hours)

Obtains an instance of ZoneOffset using an offset in hours.

14static ZoneOffset ofHoursMinutes(int hours, int minutes)

Obtains an instance of ZoneOffset using an offset in hours and minutes.

15static ZoneOffset ofHoursMinutesSeconds(int hours, int minutes, int seconds)

Obtains an instance of ZoneOffset using an offset in hours, minutes and seconds.

16static ZoneOffset ofTotalSeconds(int totalSeconds)

Obtains an instance of ZoneOffset specifying the total offset in seconds.

17<R> R query(TemporalQuery<R> query)

Queries this offset using the specified query.

18ValueRange range(TemporalField field)

Gets the range of valid values for the specified field.

19String toString()

Outputs this offset as a String, using the normalized ID.

Methods inherited

This class inherits methods from the following classes &minus;

  • Java.time.ZoneId

  • Java.lang.Object