/** * Use <tt>start</tt> to create a new watch. */ private Watch() { super(); reset(); }
/** * Returns the number of units since the last call to <tt>reset</tt> or <tt>start</tt>. * * @param unit determines the desired output unit * @param reset determines if the watch should be reset, after the duration has be computed. * @return returns the duration since the start of this watch in the given <tt>TimeUnit</tt> */ public long elapsed(TimeUnit unit, boolean reset) { long result = unit.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); if (reset) { reset(); } return result; }