Javatime-instant-plusseconds
提供:Dev Guides
java.time.Instant.plusSeconds()メソッドの例
説明
- java.time.Instant.plusSeconds(long secondsToAdd)*メソッドは、指定された期間(秒単位)が追加されたこのインスタントのコピーを返します。
宣言
以下は、* java.time.Instant.plusSeconds(long secondsToAdd)*メソッドの宣言です。
public Instant plusSeconds(long secondsToAdd)
パラメーター
*secondsToAdd* -追加する秒数、正または負。
戻り値
指定された秒が追加されたこのインスタントに基づくインスタント、null以外。
例外
- DateTimeException -結果が最大または最小インスタントを超える場合。
- ArithmeticException -数値オーバーフローが発生した場合。
例
次の例は、java.time.Instant.plusSeconds(long secondsToAdd)メソッドの使用方法を示しています。
package com.finddevguides;
import java.time.Instant;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.parse("2017-02-03T10:37:30.00Z");
Instant result = instant.plusSeconds(10);
System.out.println(result);
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
2017-02-03T10:37:40Z