public synchronized long elapsed(TimeUnit unit) {
        final long elapsed;
        switch (state) {
        case RUNNING:
            elapsed = System.nanoTime() - nanoTimeStart;
            break;

        case STOPPED:
            elapsed = nanoTimeStop - nanoTimeStart;
            break;

        default:
            throw new IllegalStateException("State: " + state.toString());
        }
        if (unit == null) {
            throw new NullPointerException("unit");
        }

        return unit.convert(elapsed, TimeUnit.NANOSECONDS);            
    }