Java Data Type How to - Create Instant from Epoch second








Question

We would like to know how to create Instant from Epoch second.

Answer

import java.time.Instant;

public class Main {
  public static void main(String[] args) {
    Instant firstInstant = Instant.ofEpochSecond(1234881180); 

    System.out.println(firstInstant);
  }
}

The code above generates the following result.