Returns a string representation of the current elapsed time.
()
| 203 | */ |
| 204 | |
| 205 | @Override |
| 206 | public String toString() { |
| 207 | long nanos = elapsedNanos(); |
| 208 | TimeUnit unit = chooseUnit(nanos); |
| 209 | double value = (double) nanos / NANOSECONDS.convert(1, unit); |
| 210 | |
| 211 | // Too bad this functionality is not exposed as a regular method call |
| 212 | return Platform.formatCompact4Digits(value) + " " + abbreviate(unit); |
| 213 | } |
| 214 | |
| 215 | private static TimeUnit chooseUnit(long nanos) { |
| 216 | if (DAYS.convert(nanos, NANOSECONDS) > 0) { |
nothing calls this directly
no test coverage detected