long toEpochSecond()
描述 (Description)
java.time.OffsetDateTime.toEpochSecond()方法将此日期时间转换为1970-01-01T00:00:00Z的纪元的秒数。
声明 (Declaration)
以下是java.time.OffsetDateTime.toEpochSecond()方法的声明。
public long toEpochSecond()
返回值 (Return Value)
1970-01-01T00:00:00Z时代的秒数。
例子 (Example)
以下示例显示了java.time.OffsetDateTime.toEpochSecond()方法的用法。
package com.iowiki;
import java.time.OffsetDateTime;
public class OffsetDateTimeDemo {
public static void main(String[] args) {
OffsetDateTime date = OffsetDateTime.now();
System.out.println(date.toEpochSecond());
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
1490085824