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)

從臨時物件獲取 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> R query(TemporalQuery<R> query)

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

18 ValueRange range(TemporalField field)

獲取指定欄位的有效值範圍。

19 String toString()

使用規範化的 ID 將此偏移量輸出為字串。

繼承的方法

此類繼承自以下類的方法:

  • Java.time.ZoneId
  • Java.lang.Object
廣告