Code example for TimeUnit

Methods: convert, ordinal

0
        /* Too bad this functionality is not exposed as a regular method call */ 
        return String.format("%." + significantDigits + "g %s", mValue, abbreviate(mUnit));
    } 
 
    private static TimeUnit chooseUnit(final long nanos) {
        if (SECONDS.convert(nanos, NANOSECONDS) > 0) {
            return SECONDS;
        } 
        if (MILLISECONDS.convert(nanos, NANOSECONDS) > 0) {
            return MILLISECONDS;
        } 
        if (MICROSECONDS.convert(nanos, NANOSECONDS) > 0) {
            return MICROSECONDS;
        } 
        return NANOSECONDS;
    } 
 
    private static String abbreviate(final TimeUnit unit) {
        switch (unit) {
            case NANOSECONDS:
                return "ns"; 
            case MICROSECONDS:
                return "\u03bcs"; 
            case MILLISECONDS: