java.time.OffsetTime.plus(TemporalAmount amountToAdd)
方法返回此時間的副本,並新增了指定的數量。
以下是java.time.OffsetTime.plus(TemporalAmount amountToAdd)
方法的宣告。
public OffsetTime plus(TemporalAmount amountToAdd)
amountToAdd
- 要新增的數量,而不是null
。基於此時間的OffsetTime
,新增了指定的數量,而不是null
。
DateTimeException
- 如果無法新增。ArithmeticException
- 如果發生數位溢位。以下範例顯示了java.time.OffsetTime.plus(TemporalAmount amountToAdd)
方法的用法。
package com.yiibai;
import java.time.Duration;
import java.time.OffsetTime;
public class OffsetTimeDemo {
public static void main(String[] args) {
OffsetTime time = OffsetTime.parse("10:15:30+01:00");
OffsetTime time1 = time.plus(Duration.ofHours(10));
System.out.println(time1);
}
}
編譯並執行上面的程式,這將產生以下結果 -
20:15:30+01:00