Close

Java Date Time - Instant.getEpochSecond() Examples

Java Date Time Java Java API 


Class:

java.time.Instant

java.lang.Objectjava.lang.Objectjava.time.Instantjava.time.Instantjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public long getEpochSecond()

Returns the number of seconds from the Java epoch of 1970-01-01T00:00:00Z.


Examples


package com.logicbig.example.instant;

import java.time.Instant;

public class GetEpochSecondExample {

public static void main(String... args) {
Instant i = Instant.now();
System.out.println(i);

long s = i.getEpochSecond();
System.out.println(s);
}
}

Output

2017-05-01T20:57:57.714Z
1493672277




See Also