time since JVM started
Use this snippet:
long jvmUpTime = ManagementFactory.getRuntimeMXBean().getUptime();
or:
long jvmStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
This is the correct way of retrieving JVM up-time.
For more info see RuntimeMXBean
You can get the start time of the JVM in the following code:
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
...
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
long uptimeInMillis = runtimeMXBean.getUptime();
See more are https://docs.oracle.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html.
if your jvm program running in linux, you can view the startTime use ps
ps -p <pid> -o stime,etime