Unix Timestamp in Java
Look up the current epoch time and convert between Unix seconds and UTC dates in Java.
Get the current timestamp
import java.time.Instant;
class Main {
public static void main(String[] args) {
System.out.println(Instant.now().getEpochSecond());
}
}Timestamp to date
import java.time.Instant;
class Main {
public static void main(String[] args) {
System.out.println(Instant.ofEpochSecond(1_700_000_000L));
}
}Date to timestamp
import java.time.Instant;
class Main {
public static void main(String[] args) {
System.out.println(Instant.parse("2023-11-14T22:13:20Z").getEpochSecond());
}
}Open 1700000000 in the converter
Current Unix time
Seconds—
Milliseconds—
- UTC
- —
- My time zone
- —
Free to use. Your input stays in this browser.
How to use it
- Copy the current-time example into your Java environment to read Unix seconds.
- Run the second example to display 1700000000 as a UTC date.
- Run the last example to convert that date back into seconds.
Instant keeps seconds and a nanosecond adjustment. System.currentTimeMillis() and Instant.toEpochMilli() return milliseconds, so check the API before exchanging values.