@Test
public void test4() throws InterruptedException {
StopWatch sw = new StopWatch();
sw.start();
Thread.sleep(1000);
sw.stop();
System.out.println(getStartedMessage(sw));
}
private StringBuilder getStartedMessage(StopWatch stopWatch) {
StringBuilder message = new StringBuilder();
message.append("Started ");
message.append(" in ");
message.append(stopWatch.getTotalTimeSeconds());
try {
double uptime = (double) ManagementFactory.getRuntimeMXBean().getUptime() / 1000.0D;
message.append(" seconds (JVM running for " + uptime + ")");
} catch (Throwable var5) {
}
return message;
}
打印时间差工具类
最新推荐文章于 2024-07-23 21:41:01 发布