Skip to content

Commit 1b4714c

Browse files
committed
Add sample code to get current timestamp in Java 8
1 parent ba4fb5b commit 1b4714c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.baeldung.util;
2+
3+
import java.time.Instant;
4+
5+
public class GetCurrentTimestamp {
6+
7+
public static void main(String args[]) {
8+
9+
Instant instant = Instant.now();
10+
System.out.println("Current timestamp is: " + instant.toEpochMilli());
11+
12+
System.out.println("Number of seconds: " + instant.getEpochSecond());
13+
}
14+
}

0 commit comments

Comments
 (0)