Add sample code to get current timestamp in Java 8
This commit is contained in:
parent
ba4fb5bf42
commit
1b4714c214
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue