Returns a string representation of the current elapsed time.
()
| 188 | * Returns a string representation of the current elapsed time. |
| 189 | */ |
| 190 | @Override |
| 191 | public String toString() { |
| 192 | long nanos = elapsedNanos(); |
| 193 | |
| 194 | TimeUnit unit = chooseUnit(nanos); |
| 195 | double value = (double) nanos / NANOSECONDS.convert(1, unit); |
| 196 | |
| 197 | // Too bad this functionality is not exposed as a regular method call |
| 198 | return Platform.formatCompact4Digits(value) + " " + abbreviate(unit); |
| 199 | } |
| 200 | |
| 201 | private static TimeUnit chooseUnit(long nanos) { |
| 202 | if (DAYS.convert(nanos, NANOSECONDS) > 0) { |
nothing calls this directly
no test coverage detected