- java.time 包類
- java.time - 主頁
- java.time - 時鐘
- java.time - 持續時間
- java.time - instant
- java.time - LocalDate
- java.time - LocalDateTime
- java.time - LocalTime
- java.time - MonthDay
- java.time - OffsetDateTime
- java.time - OffsetTime
- java.time - 週期
- java.time - 年
- java.time - YearMonth
- java.time - ZonedDateTime
- java.time - ZoneId
- java.time - ZoneOffset
- java.time 包列舉
- java.time - 月
- java.time 有用資源
- java.time - 討論
java.time.Instant.adjustInto() 方法示例
說明
java.time.Instant.adjustInto(Temporal temporal) 方法調整指定的時間物件以採用此 instant。
申明
以下是 java.time.Instant.adjustInto(Temporal temporal) 方法的宣告。
public Temporal adjustInto(Temporal temporal)
引數
temporal - 要調整的目標物件,非空。
返回值
調整後的物件,非空。
異常
DateTimeException - 如果無法進行調整。
ArithmeticException - 如果發生數值溢位。
示例
以下示例演示瞭如何使用 java.time.Instant.adjustInto(Temporal temporal) 方法。
package com.tutorialspoint;
import java.time.Instant;
import java.time.ZonedDateTime;
public class InstantDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.now();
System.out.println(date);
Instant instant = Instant.parse("2017-02-03T10:37:30.00Z");
date = (ZonedDateTime)instant.adjustInto(date);
System.out.println(date);
}
}
編譯並執行上述程式,結果如下 -
2017-03-10T11:10:35.454+05:30[Asia/Calcutta] 2017-02-03T16:07:30+05:30[Asia/Calcutta]
廣告