Sunday, 12 January 2020

Get number of seconds from Jan 1st 1970


'getEpochSecond' method of Instant class return number of seconds from the Java epoch of 1970-01-01T00:00:00Z.

Example
long seconds = Instant.now().getEpochSecond();

App.java

package com.sample.app;

import java.time.Instant;

public class App {

 public static void main(String args[]){

  long seconds = Instant.now().getEpochSecond();
  
  System.out.println(seconds);
 }

}


You may like

No comments:

Post a Comment