long getLong(TemporalField field)
描述 (Description)
java.time.Instant.getLong(TemporalField field)方法从此瞬间获取指定字段的值。
声明 (Declaration)
以下是java.time.Instant.getLong(TemporalField field)方法的声明。
public long getLong(TemporalField field)
参数 (Parameters)
field - 要获取的字段,而不是null。
返回值 (Return Value)
该字段的值。
异常 (Exceptions)
DateTimeException - 如果无法获取该字段的值或该值超出该字段的有效值范围。
UnsupportedTemporalTypeException - 如果不支持该字段或值的范围超过int。
ArithmeticException - 如果发生数字溢出。
例子 (Example)
以下示例显示了java.time.Instant.getLong(TemporalField field)方法的用法。
package com.iowiki;
import java.time.Instant;
import java.time.temporal.ChronoField;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.parse("2017-03-03T10:37:30.00Z");
System.out.println(instant.getLong(ChronoField.NANO_OF_SECOND));
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
0