Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get system start time from RuntimeMXBean in Java
RuntimeMXBean in the management interface for the runtime system of the Java virtual machine.
RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();
To get the system start time, use the getStartTime() method −
new Date(runtimeMX.getStartTime()
The following is an example −
Example
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Demo {
public static void main(String args[]) throws Exception {
RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();
System.out.println("System Start Time = "+new Date(runtimeMX.getStartTime()));
}
}
Output
System Start Time = Mon Nov 26 07:03:19 UTC 2018
Advertisements