Get application uptime

后端 未结 4 1141
有刺的猬
有刺的猬 2020-12-31 02:59

I\'ve written an application in java and I want to add a feature to report the uptime of the application. Is there a Class/method in the JVM that can do this?

Should

4条回答
  •  情书的邮戳
    2020-12-31 03:49

    You can use RuntimeMXBean.getUptime()

    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
    long uptime = rb.getUptime();
    

提交回复
热议问题