java.time.Period類


java.time.Period類根據年,月和日來模擬一個數量或時間量。

類宣告

以下是java.time.Period類的宣告 -

public final class Period
   extends Object
      implements ChronoPeriod, Serializable

欄位

以下是Java.time.Period類的欄位 -

  • static Period ZERO - 零週期的常數。

類方法

編號 方法 描述
1 Temporal addTo(Temporal temporal) 將此Period新增到指定的時態物件
2 static Period between(LocalDate startInclusive, LocalDate endExclusive) 獲得一個包含兩個日期之間的年數,月數和天數的Period
3 boolean equals(Object otherPeriod) 檢查此Period是否等於指定的Period
4 static Duratio from(TemporalAmount amount) 從時間量獲得Period的範例。
5 long get(TemporalUnit unit) 獲取所請求單元的值。
6 IsoChronology getChronology() 獲取此Period的年表,即ISO日曆系統。
7 int getDays() 獲取此Period的天數。
8 int getMonths() 獲取此Period的月數。
9 List getUnits() 獲取此Period支援的單位集。
10 int hashCode() Period的雜湊碼。
11 boolean isNegative() 檢查此期間是否為負數,不包括零。
12 boolean isZero() 檢查此Period是否為零長度。
13 Period minus(TemporalAmount amountToSubtract) 返回此Period的副本,並減去指定的Period
14 Period minusDays(long daysToSubtract) 返回此Period的副本,並減去指定的天數。
15 Period minusMonths(long months) 返回此Period的副本,並減去指定的月份。
16 Period minusYears(long years) 返回此Period的副本,並減去指定的年份。
17 Period multipliedBy(long multiplicand) 返回此Period的副本乘以標量。
18 Period negated() 返回此Period的副本,其長度為negated
19 Period normalized() 返回此Period的副本,其中年份和月份已標準化。
20 static Period of(int years, int months, int days) 獲得表示若干年,月和日的時段。
21 static Period ofDays(int days) 獲得表示天數的Period
22 static Period ofMonths(int months) 獲得表示若干月份的Period
23 static Period ofWeeks(int weeks) 獲得代表若干週的Period
24 static Period ofYears(int years) 獲得代表若干週的Period
25 static Period parse(CharSequence text) 從文字字串(如PnYnMnD)獲取Period
26 Period plus(TemporalAmount amountToAdd) 返回此Period的副本,並新增指定的Period
27 Period plusDays(long daysToAdd) 返回此Period的副本,並新增指定的天數。
28 Period plusMonths(long monthsToAdd) 返回此Period的副本,並新增指定的月份。
29 Period plusYears(long yearsToAdd) 返回此Period的副本,並新增指定年份。
30 Temporal subtractFrom(Temporal temporal) 從指定的時態物件中減去此Period
31 String toString() 使用基於ISO-8601秒的表示形式的此Period的字串表示形式,例如PT8H6M12.345S
32 long toTotalMonths() 獲取此Period的總月數。
33 Period withDays(int days) 返回具有指定天數的此Period的副本。
34 Period withMonths(int months) 返回具有指定月份數的此Period的副本。
35 Period withYears(int years) 返回具有指定年數的此Period的副本。

方法繼承

該類繼承以下類中的方法 -

  • Java.lang.Object