- java.time 包類
- java.time - 首頁
- java.time - Clock
- java.time - Duration
- 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.ZonedDateTime.plusSeconds() 方法示例
說明
java.time.ZonedDateTime.plusSeconds(long seconds) 方法返回此日期時間加上指定時間的副本。
宣告
以下是對 java.time.ZonedDateTime.plusSeconds(long seconds) 方法的宣告。
public ZonedDateTime plusSeconds(long seconds)
引數
seconds - 要新增的時間(可以為負)。
返回值
ZonedDateTime 根據此日期時間加上時間,不為 null。
異常
DateTimeException - 如果結果超出支援的日期範圍。
示例
以下示例演示了 java.time.ZonedDateTime.plusSeconds(long seconds) 方法用法。
package com.tutorialspoint;
import java.time.ZonedDateTime;
public class ZonedDateTimeDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.parse("2017-03-28T12:25:38.492+05:30[Asia/Calcutta]");
System.out.println(date.plusSeconds(20));
}
}
讓我們編譯並執行上述程式,將產生以下結果 -
2017-03-28T12:25:58.492+05:30[Asia/Calcutta]
廣告