Java Date Time - LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) example








LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) gets an instance of LocalDateTime using seconds from the epoch of 1970-01-01T00:00:00Z.

Syntax

ofEpochSecond has the following syntax.

public static LocalDateTime ofEpochSecond(long epochSecond,    int nanoOfSecond,    ZoneOffset offset)

Example

The following example shows how to use ofEpochSecond.

import java.time.LocalDateTime;
import java.time.ZoneOffset;
/*from w  ww.  j a v a2  s  . c o  m*/
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.ofEpochSecond(1,1,ZoneOffset.UTC);
    
    System.out.println(a);
  }
}

The code above generates the following result.