Returns a string representation of the current elapsed time.
()
| 232 | |
| 233 | /** Returns a string representation of the current elapsed time. */ |
| 234 | @Override |
| 235 | public String toString() { |
| 236 | long nanos = elapsedNanos(); |
| 237 | |
| 238 | TimeUnit unit = chooseUnit(nanos); |
| 239 | double value = (double) nanos / NANOSECONDS.convert(1, unit); |
| 240 | |
| 241 | // Too bad this functionality is not exposed as a regular method call |
| 242 | return Platform.formatCompact4Digits(value) + " " + abbreviate(unit); |
| 243 | } |
| 244 | |
| 245 | private static TimeUnit chooseUnit(long nanos) { |
| 246 | if (DAYS.convert(nanos, NANOSECONDS) > 0) { |
nothing calls this directly
no test coverage detected