Java Data Type How to - Get current time stamp in Java 8








Question

We would like to know how to get current time stamp in Java 8.

Answer

import java.time.Instant;
public class Main {
  public static void main(String[] argv) {
    Instant timestamp = Instant.now();
    System.out.println("What is value of this instant " + timestamp);
  }
}

The code above generates the following result.