- java.time 包類
- java.time - 首頁
- java.time - 時鐘
- java.time - 持續時間
- java.time - 時間戳
- java.time - 本地日期
- java.time - 本地時間
- java.time - 本地時間
- java.time - 月日
- java.time - 偏移日期時間
- java.time - 偏移時間
- java.time - 期間
- java.time - 年份
- java.time - 年月
- java.time - 分割槽日期時間
- java.time - 時區 ID
- java.time - 時區偏移
- java.time 包列舉
- java.time - 月份
- java.time 有用資源
- java.time - 討論
java.time.OffsetTime.plusSeconds() 方法示例
描述
java.time.OffsetTime.plusSeconds(long seconds) 方法返回時間加上指定秒數的副本。
宣告
以下是 java.time.OffsetTime.plusSeconds(long seconds) 方法的宣告。
public OffsetTime plusSeconds(long seconds)
引數
seconds - 要新增的秒數,可以為負數。
返回值
根據該時間建立的 OffsetTime,其中添加了秒數,非空。
異常
DateTimeException - 如果結果超出了受支援的日期範圍。
示例
以下示例展示了 java.time.OffsetTime.plusSeconds(long seconds) 方法的用法。
package com.tutorialspoint;
import java.time.OffsetTime;
public class OffsetTimeDemo {
public static void main(String[] args) {
OffsetTime date = OffsetTime.parse("10:15:30+01:00");
System.out.println(date.plusSeconds(20));
}
}
讓我們編譯並執行上面的程式,這將產生以下結果 -
10:15:50+01:00
廣告