Java TimeUnit Calculate shortName(TimeUnit unit)

Here you can find the source of shortName(TimeUnit unit)

Description

short Name

License

Open Source License

Declaration

public static String shortName(TimeUnit unit) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.TimeUnit;

public class Main {
    public static String shortName(TimeUnit unit) {
        switch (unit) {
        case NANOSECONDS:
            return "ns";
        case MICROSECONDS:
            return "us";
        case MILLISECONDS:
            return "ms";
        case SECONDS:
            return "s";
        case MINUTES:
            return "m";
        case HOURS:
            return "h";
        case DAYS:
            return "days";
        default://from  w  w  w . j a v  a  2 s.com
            return unit.toString();
        }
    }
}

Related

  1. pause(long duration, TimeUnit unit)
  2. printTime(long time, TimeUnit unit)
  3. randomSleep(int duration, TimeUnit timeUnit)
  4. resetWithClockStep(long clockStep, TimeUnit clockStepUnit)
  5. run(final Runnable runnable, long timeout, TimeUnit unit)
  6. sleep(int duration, TimeUnit unit)
  7. sleep(long duration, TimeUnit timeUnit)
  8. sleep(long duration, TimeUnit timeUnit)
  9. sleep(long pTime, TimeUnit pTimeUnit)