Java TimeUnit Usage getUnit(long nanos)

Here you can find the source of getUnit(long nanos)

Description

get Unit

License

Open Source License

Declaration

public static TimeUnit getUnit(long nanos) 

Method Source Code


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

import java.util.concurrent.TimeUnit;

public class Main {
    public static TimeUnit getUnit(long nanos) {

        for (TimeUnit unit : TimeUnit.values()) {
            long current = unit.convert(nanos, TimeUnit.NANOSECONDS);
            if (current < 1000) {
                return unit;
            }/*from  w ww.jav  a2  s . c o  m*/
        }

        return TimeUnit.NANOSECONDS;
    }
}

Related

  1. getTimeForS3URL()
  2. getTimeInMillis(String str)
  3. getTimeString(long millis)
  4. getTimezoneOffset(TimeZone timeZone)
  5. getTomorrowTimestamp()
  6. getValidityAsString(Date endDate)
  7. getWithTimeout(final Future future)
  8. humanizeTime(long hours, long minutes, long seconds)
  9. humanizeToTime(long millis)