Add sample code to get current timestamp in Java 8

This commit is contained in:
sanketmeghani 2016-09-18 17:06:34 +05:30
parent ba4fb5bf42
commit 1b4714c214
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package com.baeldung.util;
import java.time.Instant;
public class GetCurrentTimestamp {
public static void main(String args[]) {
Instant instant = Instant.now();
System.out.println("Current timestamp is: " + instant.toEpochMilli());
System.out.println("Number of seconds: " + instant.getEpochSecond());
}
}