long toEpochMilli()
描述 (Description)
java.time.Instant.toEpochMilli()方法将此瞬间转换为1970-01-01T00:00:00Z的纪元的毫秒数。
声明 (Declaration)
以下是java.time.Instant.toEpochMilli()方法的声明。
public long toEpochMilli()
返回值 (Return Value)
自1970-01-01T00:00:00Z时代以来的毫秒数。
异常 (Exceptions)
ArithmeticException - 如果发生数字溢出。
例子 (Example)
以下示例显示了java.time.Instant.toEpochMilli()方法的用法。
package com.iowiki;
import java.time.Instant;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
System.out.println(instant.toEpochMilli());
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
1417601730000