Javatime-instant-with
提供:Dev Guides
java.time.Instant.with()メソッドの例
説明
- java.time.Instant.with(TemporalAdjuster adjuster)*メソッドは、このインスタントの調整済みコピーを返します。
宣言
以下は* java.time.Instant.with(TemporalAdjuster adjuster)*メソッドの宣言です。
public Instant with(TemporalAdjuster adjuster)
パラメーター
*adjuster* -使用するアジャスター、null以外。
戻り値
これに基づいて調整が行われたインスタント。nullではない。
例外
- DateTimeException -調整を行えない場合。
- ArithmeticException -数値オーバーフローが発生した場合。
例
次の例は、java.time.Instant.with(TemporalAdjuster adjuster)メソッドの使用方法を示しています。
package com.finddevguides;
import java.time.Instant;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.parse("2017-12-03T10:15:30.00Z");
Instant instant1 = Instant.now();
Instant result = instant.with(instant1);
System.out.println(result);
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
2017-03-15T11:06:19.656Z