java.time.OffsetDateTime.plusNanos(long nanoseconds)
方法返回此日期时间的副本,并添加指定的纳秒数。
声明
以下是java.time.OffsetDateTime.plusNanos(long nanoseconds)
方法的声明。
public OffsetDateTime plusNanos(long nanoseconds)
参数
nanoseconds
- 要添加的纳秒,可能是负数。
返回值
基于此日期时间加上纳秒的OffsetDateTime
,不为null
。
异常
DateTimeException
- 如果结果超出支持的日期范围。
示例
以下示例显示了java.time.OffsetDateTime.plusNanos(long nanoseconds)
方法的用法。
package com.zaixian;
import java.time.OffsetDateTime;
public class OffsetDateTimeDemo {
public static void main(String[] args) {
OffsetDateTime date = OffsetDateTime.parse("2017-02-03T10:15:30+01:00");
System.out.println(date.plusNanos(20000));
}
}
编译并运行上面的程序,这将产生以下结果 -
2017-02-03T10:15:30.000020+01:00