Programming Tips - Java: Get the current time in milliseconds

Date: 2016apr8 Update: 2025sep25 Language: Java Keywords: millisecond, nanosecond, nanoseconds, seconds, thousandths, epoch Level: novice Q. Java: Get the current time in milliseconds A. Full example:
class Demo { public static final void main(String []args) { final long now = System.currentTimeMillis(); System.out.println("now in milliseconds=" + now); System.out.println(" now in seconds=" + now / 1000); } }
Output (at one time):
now in milliseconds=1758806288025 now in seconds=1758806288
This is the number of milliseconds since Jan 1, 1970. Handy for timing things.