Get system start time from RuntimeMXBean in Java
Description
The following code shows how to get system start time from RuntimeMXBean.
Example
/*from w w w. j a v a 2 s . c o m*/
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(new Date(mx.getStartTime()));
}
}
The code above generates the following result.