How to get current Unix Timestamp in Java

The below code shows you the way to get current unix timestamp in Java.

TimestampExample.java
package com.bytenota;

public class TimestampExample {
    
    public static void main(String[] args) {
        long currentTimestamp = System.currentTimeMillis() / 1000L;
        System.out.println(currentTimestamp);
    }
}

Output

1512014327

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x