package org.kodejava.lang.management;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class GetStartTime {
public static void main(String[] args) {
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
// Returns the start time of the Java virtual machine in
// milliseconds. This method returns the approximate time
// when the Java virtual machine started.
long startTime = bean.getStartTime();
Date startDate = new Date(startTime);
System.out.println("Start Time = " + startTime);
System.out.println("Start Date = " + startDate);
}
}
The result of the code snippet above:
Start Time = 1634391703196
Start Date = Sat Oct 16 21:41:43 CST 2021
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024