import java.time.*; /** * * @author */ public class Clock { public static void main(String[] args){} private LocalTime startTime; private LocalTime stopTime; public Clock(){ startTime=LocalTime.now(); } /** * Set the start time * @param time: start time **/ public void start(LocalTime time){ startTime= time; } /** *Set the Stop time * @param time: stop time **/ public void stop(LocalTime time){ stopTime=time; } /** * This method will return total elapsed time **/ public int getElapsedTime(){ return (stopTime.toSecondOfDay() -startTime.toSecondOfDay()); }//End Main }//End Class
import java.time.*; /** * * @author */ public class TestClock { public static void main (String[] args){ Clock clock=new Clock(); clock.start(LocalTime.parse(args[0])); clock.stop(LocalTime.parse(args[1])); System.out.println("Elapsed time in seconds is: "+clock.getElapsedTime()); }//End Main }//End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)