java.time.OffsetTime.adjustInto(Temporal temporal)
方法將指定的時態物件調整為與此物件具有相同的時間。
以下是java.time.OffsetTime.adjustInto(Temporal temporal)
方法的宣告。
public Temporal adjustInto(Temporal temporal)
temporal
- 要調整的目標物件,而不是null
。調整後的物件,不為空。
DateTimeException
- 如果無法進行調整。ArithmeticException
- 如果發生數位溢位。以下範例顯示了java.time.OffsetTime.adjustInto(Temporal temporal)
方法的用法。
package com.yiibai;
import java.time.OffsetTime;
import java.time.ZonedDateTime;
public class OffsetTimeDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.now();
System.out.println(date);
OffsetTime date1 = OffsetTime.parse("12:30:30+01:00");
date = (ZonedDateTime)date1.adjustInto(date);
System.out.println(date);
}
}
編譯並執行上面的程式,這將產生以下結果 -
2017-03-21T16:58:09.052+05:30[Asia/Calcutta]
2017-03-21T12:30:30+05:30[Asia/Calcutta]