java.time.Instant.with() 方法
描述
java.time.Instant.with(TemporalAdjusteradjuster) 方法返回此瞬间的调整副本。
声明
以下是 java.time.Instant.with(TemporalAdjuster adjuster) 方法的声明。
public Instant with(TemporalAdjuster adjuster)
参数
adjuster − 要使用的调节器,不为空。
返回值
一个基于此的 Instant 并进行了调整,而不是 null。
异常
DateTimeException − 如果无法进行调整。
ArithmeticException − 如果发生数字溢出。
示例
下面的例子展示了 java.time.Instant.with(TemporalAdjuster adjuster) 方法的使用。
package com.tutorialspoint;
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

