java.time.ZoneOffset類

java.time.ZoneOffset類表示格林威治/UTC的時區偏移量,例如+02:00

類聲明

以下是java.time.ZoneOffset類的聲明 -

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

類方法

編號

方法

描述

1

Temporal adjustInto(Temporal temporal)

調整指定的時態對象以使其具有與此對象相同的偏移量。

2

int compareTo(ZoneOffset other)

將此偏移量按降序與另一個偏移量進行比較。

3

boolean equals(Object obj)

檢查此偏移量是否等於另一個偏移量。

4

static ZoneOffset from(TemporalAccessor temporal)

temporal對象獲取ZoneOffset的實例。

5

int get(TemporalField field)

從此偏移量中獲取指定字段的int值。

6

String getId()

獲取規範化區域偏移ID。

7

long getLong(TemporalField field)

從此偏移量中獲取指定字段的long值。

8

ZoneRules getRules()

獲取關聯的時區規則。

9

int getTotalSeconds()

獲取以秒爲單位的總區域偏移量。

10

int hashCode()

11

boolean isSupported(TemporalField field)

此偏移的哈希碼。

12

static ZoneOffset of(String offsetId)

使用ID獲取ZoneOffset的實例。

13

static ZoneOffset ofHours(int hours)

使用小時偏移量獲取ZoneOffset的實例。

14

static ZoneOffset ofHoursMinutes(int hours, int minutes)

使用小時和分鐘的偏移量獲取ZoneOffset的實例。

15

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

使用小時,分鐘和秒的偏移量獲取ZoneOffset的實例。

16

static ZoneOffset ofTotalSeconds(int totalSeconds)

獲取以秒爲單位指定總偏移量ZoneOffset的實例。

17

R query(TemporalQuery query)

使用指定的查詢來查詢此偏移量。

18

ValueRange range(TemporalField field)

獲取指定字段的有效值範圍。

19

String toString()

使用規範化ID將此偏移量輸出爲String