java.time.OffsetTime.plusNanos(long nanoseconds)
方法返回此時間的副本,並添加指定的納秒數。
聲明
以下是java.time.OffsetTime.plusNanos(long nanoseconds)
方法的聲明。
public OffsetTime plusNanos(long nanoseconds)
參數
nanoseconds
- 要添加的納秒,可能是負數。
返回值
基於此時間的OffsetTime
,加上納秒,不為null
。
異常
DateTimeException
- 如果結果超出支持的日期範圍。
示例
以下示例顯示了java.time.OffsetTime.plusNanos(long nanoseconds)
方法的用法。
package com.zaixian;
import java.time.OffsetTime;
public class OffsetTimeDemo {
public static void main(String[] args) {
OffsetTime date = OffsetTime.parse("10:15:30+01:00");
System.out.println(date.plusNanos(20000));
}
}
編譯並運行上面的程式,這將產生以下結果 -
10:15:30.000020+01:00
上一篇:
java.time.OffsetTime類
下一篇:
java.time.Period類