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.zaixian;
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
上一篇:
java.time.Instant類
下一篇:
java.time.LocalDate類