Timestamp To Date Converter
Convert timestamp to date or date to timestamp easily
How To Get Current Timestamp In Java
There are multiple ways how to get current timestamp in Java. One way is to use module System and the other way is to use module Date. Unlike other languages Java provides number of miliseconds elapsed since 1 January 1970 00:00:00 UTC. Other languages provides mostly just number of seconds.
Using System
Module System
provides function currentTimeMillis
which returns number of miliseconds elapsed since beginning of the epoch.
long ts = System.currentTimeMillis();
System.out.println(ts);
# -442240354
Using Date.getTime()
Module Date
provides function getTime()
which returns number of miliseconds elapsed since beginning of the epoch.
import java.util.Date;
// ...
long ts = (new Date()).getTime();
System.out.println(ts);
# -442240354
Tags
Related Articles
- How To Get Current Timestamp In Bash
- How To Get Current Timestamp In JavaScript
- How To Get Current Timestamp In PHP
- How To Get Current Timestamp In Python
- How To Convert Timestamp To Date and Time in JavaScript
- How To Convert Timestamp To Date and Time in Python
- How To Get Current Date And Time in JavaScript
- How To Get Current Time In Python