Answers for "java chronometer"

0

java chronometer

public class Chrono {

	private boolean running;
	private long startTime;

	public Chrono(){
		running = false;
	}
	
	public void start(){
		running = true;
		startTime = System.currentTimeMillis();
	}
	
	public void stop(){
		startTime = getTime();
		running = false;
	}
	
	public long getTime(){
		if (running){
			return 	System.currentTimeMillis() - startTime;
		} else {
			return startTime;
		}
	}
}
Posted by: Guest on March-01-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language