java.time.OffsetTime.with(TemporalAdjuster adjuster)
方法返回此次調整後的副本。
以下是java.time.OffsetTime.with(TemporalAdjuster adjuster)
方法的宣告。
public OffsetTime with(TemporalAdjuster adjuster)
adjuster
- 要使用的調整器,而不是null
。基於此的OffsetTime
進行調整,而不是null
。
DateTimeException
- 如果無法進行調整。ArithmeticException
- 如果發生數位溢位。以下範例顯示了java.time.OffsetTime.with(TemporalAdjuster adjuster)
方法的用法。
package com.yiibai;
import java.time.LocalTime;
import java.time.OffsetTime;
public class OffsetTimeDemo {
public static void main(String[] args) {
OffsetTime date = OffsetTime.parse("10:15:30+01:00");
OffsetTime result = date.with(LocalTime.NOON);
System.out.println(result);
}
}
編譯並執行上面的程式,這將產生以下結果 -
12:00+01:00