
org.zeroturnaround.process.Stopwatch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zt-process Show documentation
Show all versions of zt-process Show documentation
A library for stopping external processes from Java.
The newest version!
package org.zeroturnaround.process;
import java.util.concurrent.TimeUnit;
/**
* Simple stopwatch implementation.
*/
class Stopwatch {
private final long start;
private volatile long stop;
private Stopwatch(long start) {
this.start = start;
}
public static Stopwatch createStarted() {
return new Stopwatch(System.currentTimeMillis());
}
public Stopwatch stop() {
stop = System.currentTimeMillis();
return this;
}
public long elapsed(TimeUnit desiredUnit) {
return desiredUnit.convert(stop - start, TimeUnit.MILLISECONDS);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy