current time millis in java code example
Example 1: java get current milliseconds
package com.tutorialspoint;
import java.lang.*;
public class SystemDemo {
public static void main(String[] args) {
System.out.print("Current Time in milliseconds = ");
System.out.println(System.currentTimeMillis());
}
}
Example 2: system.currenttimemillis()
long totalMilliseconds = System.currentTimeMillis();
long totalSeconds = totalMilliseconds / 1000;
long currentSeconds = totalSeconds % 60;
long totalMinutes = totalSeconds / 60;
long currentMinutes = totalMinutes % 60;
long totalHours = totalMinutes / 60;
long currentHours = totalHours % 24;