- 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 - Period
- java.time - Year
- java.time - YearMonth
- java.time - ZonedDateTime
- java.time - ZoneId
- java.time - ZoneOffset
- java.time 包列舉
- java.time - Month
- java.time 有用資源
- java.time - 討論
java.time.Instant.plus() 方法示例
說明
java.time.Instant.plus(TemporalAmount amountToAdd) 方法返回已新增指定時間量此 instant 的副本。
宣告
以下是 java.time.Instant.plus(TemporalAmount amountToAdd) 方法的宣告。
public Instant plus(TemporalAmount amountToAdd)
Instant plus(TemporalAmount amountToAdd)
引數
amountToAdd - 要新增的時間量,非 null。
返回值
一個 Instant,基於此 instant,加上指定的時間量,非 null。
異常
DateTimeException - 如果無法進行新增。
ArithmeticException - 如果出現數字上溢。
示例
package com.tutorialspoint;
import java.time.Instant;
import java.time.Duration;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.parse("2017-02-03T10:37:30.00Z");
Duration duration = Duration.ofHours(5);
Instant result = instant.plus(duration);
System.out.println(result);
}
}
直接觀看示例
2017-02-03T15:37:30Z
列印頁面
廣告