# TimeUnit

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Enums](https://developer.android.com/reference/java/util/concurrent/TimeUnit#enumconstants)\|[Methods](https://developer.android.com/reference/java/util/concurrent/TimeUnit#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/concurrent/TimeUnit#inhmethods)  

# TimeUnit

`
public

final

enum
TimeUnit
`  
`


``

extends `[Enum](https://developer.android.com/reference/java/lang/Enum)`<`[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)`>


``


`

|---|---|-------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.lang.Enum](https://developer.android.com/reference/java/lang/Enum)\<[java.util.concurrent.TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)\> ||
|   | ↳ | java.util.concurrent.TimeUnit |

<br />

*** ** * ** ***

A`TimeUnit`represents time durations at a given unit of granularity and provides utility methods to convert across units, and to perform timing and delay operations in these units. A`TimeUnit`does not maintain time information, but only helps organize and use time representations that may be maintained separately across various contexts. A nanosecond is defined as one thousandth of a microsecond, a microsecond as one thousandth of a millisecond, a millisecond as one thousandth of a second, a minute as sixty seconds, an hour as sixty minutes, and a day as twenty four hours.

A`TimeUnit`is mainly used to inform time-based methods how a given timing parameter should be interpreted. For example, the following code will timeout in 50 milliseconds if the[lock](https://developer.android.com/reference/java/util/concurrent/locks/Lock)is not available:  

     Lock lock = ...;
     if (lock.tryLock(50L, TimeUnit.MILLISECONDS)) ...

while this code will timeout in 50 seconds:  

     Lock lock = ...;
     if (lock.tryLock(50L, TimeUnit.SECONDS)) ...

Note however, that there is no guarantee that a particular timeout implementation will be able to notice the passage of time at the same granularity as the given`TimeUnit`.

<br />

## Summary

|                                                                      ### Enum values                                                                      ||
|-----------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | `DAYS` Time unit representing twenty four hours.                       |
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | `HOURS` Time unit representing sixty minutes.                          |
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | `MICROSECONDS` Time unit representing one thousandth of a millisecond. |
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | `MILLISECONDS` Time unit representing one thousandth of a second.      |
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | `MINUTES` Time unit representing sixty seconds.                        |
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | `NANOSECONDS` Time unit representing one thousandth of a microsecond.  |
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | `SECONDS` Time unit representing one second.                           |

|                                                                                                                                                                                                                     ### Public methods                                                                                                                                                                                                                      ||
|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` long`                                                                                             | ` `[convert](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit))`(long sourceDuration, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` sourceUnit) ` Converts the given time duration in the given unit to this unit.                            |
| ` long`                                                                                             | ` `[convert](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(java.time.Duration))`(`[Duration](https://developer.android.com/reference/java/time/Duration)` duration) ` Converts the given time duration to this unit.                                                                                                   |
| ` static `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)         | ` `[of](https://developer.android.com/reference/java/util/concurrent/TimeUnit#of(java.time.temporal.ChronoUnit))`(`[ChronoUnit](https://developer.android.com/reference/java/time/temporal/ChronoUnit)` chronoUnit) ` Converts a`ChronoUnit`to the equivalent`TimeUnit`.                                                                               |
| ` void`                                                                                             | ` `[sleep](https://developer.android.com/reference/java/util/concurrent/TimeUnit#sleep(long))`(long timeout) ` Performs a[Thread.sleep](https://developer.android.com/reference/java/lang/Thread#sleep(long,%20int))using this time unit.                                                                                                              |
| ` void`                                                                                             | ` `[timedJoin](https://developer.android.com/reference/java/util/concurrent/TimeUnit#timedJoin(java.lang.Thread,%20long))`(`[Thread](https://developer.android.com/reference/java/lang/Thread)` thread, long timeout) ` Performs a timed[Thread.join](https://developer.android.com/reference/java/lang/Thread#join(long,%20int))using this time unit. |
| ` void`                                                                                             | ` `[timedWait](https://developer.android.com/reference/java/util/concurrent/TimeUnit#timedWait(java.lang.Object,%20long))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj, long timeout) ` Performs a timed[Object.wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))using this time unit.    |
| ` `[ChronoUnit](https://developer.android.com/reference/java/time/temporal/ChronoUnit)              | ` `[toChronoUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toChronoUnit())`() ` Converts this`TimeUnit`to the equivalent`ChronoUnit`.                                                                                                                                                                                     |
| ` long`                                                                                             | ` `[toDays](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toDays(long))`(long duration) ` Equivalent to[DAYS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).                                                                   |
| ` long`                                                                                             | ` `[toHours](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toHours(long))`(long duration) ` Equivalent to[HOURS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).                                                                |
| ` long`                                                                                             | ` `[toMicros](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toMicros(long))`(long duration) ` Equivalent to[MICROSECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).                                                       |
| ` long`                                                                                             | ` `[toMillis](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toMillis(long))`(long duration) ` Equivalent to[MILLISECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).                                                       |
| ` long`                                                                                             | ` `[toMinutes](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toMinutes(long))`(long duration) ` Equivalent to[MINUTES.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).                                                          |
| ` long`                                                                                             | ` `[toNanos](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toNanos(long))`(long duration) ` Equivalent to[NANOSECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).                                                          |
| ` long`                                                                                             | ` `[toSeconds](https://developer.android.com/reference/java/util/concurrent/TimeUnit#toSeconds(long))`(long duration) ` Equivalent to[SECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).                                                          |
| ` static `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)         | ` `[valueOf](https://developer.android.com/reference/java/util/concurrent/TimeUnit#valueOf(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) `                                                                                                                                                            |
| ` static final `[TimeUnit[]](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | ` `[values](https://developer.android.com/reference/java/util/concurrent/TimeUnit#values())`() `                                                                                                                                                                                                                                                       |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Enum](https://developer.android.com/reference/java/lang/Enum)` ` |---------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` final `[Object](https://developer.android.com/reference/java/lang/Object)                 | ` `[clone](https://developer.android.com/reference/java/lang/Enum#clone())`() ` Throws CloneNotSupportedException.                                                                                                                                                                                                                                                 | | ` final int`                                                                                | ` `[compareTo](https://developer.android.com/reference/java/lang/Enum#compareTo(E))`(`[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` o) ` Compares this enum with the specified object for order.                                                                                                                              | | ` final boolean`                                                                            | ` `[equals](https://developer.android.com/reference/java/lang/Enum#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` other) ` Returns true if the specified object is equal to this enum constant.                                                                                                                   | | ` final void`                                                                               | ` `[finalize](https://developer.android.com/reference/java/lang/Enum#finalize())`() ` enum classes cannot have finalize methods.                                                                                                                                                                                                                                   | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<E>`              | ` `[getDeclaringClass](https://developer.android.com/reference/java/lang/Enum#getDeclaringClass())`() ` Returns the Class object corresponding to this enum constant's enum type.                                                                                                                                                                                  | | ` final int`                                                                                | ` `[hashCode](https://developer.android.com/reference/java/lang/Enum#hashCode())`() ` Returns a hash code for this enum constant.                                                                                                                                                                                                                                  | | ` final `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[name](https://developer.android.com/reference/java/lang/Enum#name())`() ` Returns the name of this enum constant, exactly as declared in its enum declaration.                                                                                                                                                                                                 | | ` final int`                                                                                | ` `[ordinal](https://developer.android.com/reference/java/lang/Enum#ordinal())`() ` Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).                                                                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String)                       | ` `[toString](https://developer.android.com/reference/java/lang/Enum#toString())`() ` Returns the name of this enum constant, as contained in the declaration.                                                                                                                                                                                                     | | ` static <T extends `[Enum](https://developer.android.com/reference/java/lang/Enum)`<T>> T` | ` `[valueOf](https://developer.android.com/reference/java/lang/Enum#valueOf(java.lang.Class<T>,%20java.lang.String))`(`[Class](https://developer.android.com/reference/java/lang/Class)`<T> enumClass, `[String](https://developer.android.com/reference/java/lang/String)` name) ` Returns the enum constant of the specified enum class with the specified name. | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[java.lang.Comparable](https://developer.android.com/reference/java/lang/Comparable)` ` |-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract int` | ` `[compareTo](https://developer.android.com/reference/java/lang/Comparable#compareTo(T))`(E o) ` Compares this object with the specified object for order. | ||

## Enum values

### DAYS

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final TimeUnit DAYS
```

Time unit representing twenty four hours.

<br />

### HOURS

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final TimeUnit HOURS
```

Time unit representing sixty minutes.

<br />

### MICROSECONDS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final TimeUnit MICROSECONDS
```

Time unit representing one thousandth of a millisecond.

<br />

### MILLISECONDS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final TimeUnit MILLISECONDS
```

Time unit representing one thousandth of a second.

<br />

### MINUTES

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final TimeUnit MINUTES
```

Time unit representing sixty seconds.

<br />

### NANOSECONDS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final TimeUnit NANOSECONDS
```

Time unit representing one thousandth of a microsecond.

<br />

### SECONDS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final TimeUnit SECONDS
```

Time unit representing one second.

<br />

## Public methods

### convert

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long convert (long sourceDuration, 
                TimeUnit sourceUnit)
```

Converts the given time duration in the given unit to this unit. Conversions from finer to coarser granularities truncate, so lose precision. For example, converting`999`milliseconds to seconds results in`0`. Conversions from coarser to finer granularities with arguments that would numerically overflow saturate to`Long.MIN_VALUE`if negative or`Long.MAX_VALUE`if positive.

For example, to convert 10 minutes to milliseconds, use:`TimeUnit.MILLISECONDS.convert(10L, TimeUnit.MINUTES)`

<br />

|                                  Parameters                                  ||
|------------------|------------------------------------------------------------|
| `sourceDuration` | `long`: the time duration in the given`sourceUnit` <br />  |
| `sourceUnit`     | `TimeUnit`: the unit of the`sourceDuration`argument <br /> |

|                                                                              Returns                                                                              ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration in this unit, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

### convert

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long convert (Duration duration)
```

Converts the given time duration to this unit.

For any TimeUnit`unit`,`unit.convert(Duration.ofNanos(n))`is equivalent to`unit.convert(n, NANOSECONDS)`, and`unit.convert(Duration.of(n, unit.toChronoUnit()))`is equivalent to`n`(in the absence of overflow).

<br />

##### API Note:

- This method differs from[Duration.toNanos()](https://developer.android.com/reference/java/time/Duration#toNanos())in that it does not throw[ArithmeticException](https://developer.android.com/reference/java/lang/ArithmeticException)on numeric overflow.

|                    Parameters                    ||
|------------|--------------------------------------|
| `duration` | `Duration`: the time duration <br /> |

|                                                                              Returns                                                                              ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration in this unit, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

|                                                       Throws                                                        ||
|------------------------------------------------------------------------------------------------|---------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if`duration`is null |

**See also:**

- [Duration.of(long, TemporalUnit)](https://developer.android.com/reference/java/time/Duration#of(long,%20java.time.temporal.TemporalUnit))  

### of

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static TimeUnit of (ChronoUnit chronoUnit)
```

Converts a`ChronoUnit`to the equivalent`TimeUnit`.

<br />

|                          Parameters                          ||
|--------------|------------------------------------------------|
| `chronoUnit` | `ChronoUnit`: the ChronoUnit to convert <br /> |

|                                                           Returns                                                           ||
|-----------------------------------------------------------------------------------|------------------------------------------|
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | the converted equivalent TimeUnit <br /> |

|                                                                      Throws                                                                      ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`chronoUnit`has no equivalent TimeUnit |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if`chronoUnit`is null                    |

### sleep

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void sleep (long timeout)
```

Performs a[Thread.sleep](https://developer.android.com/reference/java/lang/Thread#sleep(long,%20int))using this time unit. This is a convenience method that converts time arguments into the form required by the`Thread.sleep`method.

<br />

|                                                Parameters                                                ||
|-----------|-----------------------------------------------------------------------------------------------|
| `timeout` | `long`: the minimum time to sleep. If less than or equal to zero, do not sleep at all. <br /> |

|                                                            Throws                                                             ||
|------------------------------------------------------------------------------------------------|-------------------------------|
| [InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException) | if interrupted while sleeping |

### timedJoin

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void timedJoin (Thread thread, 
                long timeout)
```

Performs a timed[Thread.join](https://developer.android.com/reference/java/lang/Thread#join(long,%20int))using this time unit. This is a convenience method that converts time arguments into the form required by the`Thread.join`method.

<br />

|                                               Parameters                                               ||
|-----------|---------------------------------------------------------------------------------------------|
| `thread`  | `Thread`: the thread to wait for <br />                                                     |
| `timeout` | `long`: the maximum time to wait. If less than or equal to zero, do not wait at all. <br /> |

|                                                            Throws                                                            ||
|------------------------------------------------------------------------------------------------|------------------------------|
| [InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException) | if interrupted while waiting |

### timedWait

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void timedWait (Object obj, 
                long timeout)
```

Performs a timed[Object.wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))using this time unit. This is a convenience method that converts timeout arguments into the form required by the`Object.wait`method.

For example, you could implement a blocking`poll`method (see[BlockingQueue.poll](https://developer.android.com/reference/java/util/concurrent/BlockingQueue#poll(long,%20java.util.concurrent.TimeUnit))) using:  

     public E poll(long timeout, TimeUnit unit)
         throws InterruptedException {
       synchronized (lock) {
         while (isEmpty()) {
           unit.timedWait(lock, timeout);
           ...
         }
       }
     }

<br />

<br />

|                                               Parameters                                               ||
|-----------|---------------------------------------------------------------------------------------------|
| `obj`     | `Object`: the object to wait on <br />                                                      |
| `timeout` | `long`: the maximum time to wait. If less than or equal to zero, do not wait at all. <br /> |

|                                                            Throws                                                            ||
|------------------------------------------------------------------------------------------------|------------------------------|
| [InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException) | if interrupted while waiting |

### toChronoUnit

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public ChronoUnit toChronoUnit ()
```

Converts this`TimeUnit`to the equivalent`ChronoUnit`.

<br />

|                                                             Returns                                                             ||
|-------------------------------------------------------------------------------------|--------------------------------------------|
| [ChronoUnit](https://developer.android.com/reference/java/time/temporal/ChronoUnit) | the converted equivalent ChronoUnit <br /> |

### toDays

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long toDays (long duration)
```

Equivalent to[DAYS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `duration` | `long`: the duration <br /> |

|                Returns                ||
|--------|-------------------------------|
| `long` | the converted duration <br /> |

### toHours

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long toHours (long duration)
```

Equivalent to[HOURS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `duration` | `long`: the duration <br /> |

|                                                                       Returns                                                                        ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

### toMicros

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long toMicros (long duration)
```

Equivalent to[MICROSECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `duration` | `long`: the duration <br /> |

|                                                                       Returns                                                                        ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

### toMillis

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long toMillis (long duration)
```

Equivalent to[MILLISECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `duration` | `long`: the duration <br /> |

|                                                                       Returns                                                                        ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

### toMinutes

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long toMinutes (long duration)
```

Equivalent to[MINUTES.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `duration` | `long`: the duration <br /> |

|                                                                       Returns                                                                        ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

### toNanos

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long toNanos (long duration)
```

Equivalent to[NANOSECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `duration` | `long`: the duration <br /> |

|                                                                       Returns                                                                        ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

### toSeconds

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long toSeconds (long duration)
```

Equivalent to[SECONDS.convert(duration, this)](https://developer.android.com/reference/java/util/concurrent/TimeUnit#convert(long,%20java.util.concurrent.TimeUnit)).

<br />

|               Parameters                ||
|------------|-----------------------------|
| `duration` | `long`: the duration <br /> |

|                                                                       Returns                                                                        ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | the converted duration, or`Long.MIN_VALUE`if conversion would negatively overflow, or`Long.MAX_VALUE`if it would positively overflow. <br /> |

### valueOf

```
public static TimeUnit valueOf (String name)
```

<br />

<br />

|       Parameters        ||
|--------|-----------------|
| `name` | `String` <br /> |

|                                          Returns                                          ||
|-----------------------------------------------------------------------------------|--------|
| [TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | <br /> |

### values

```
public static final TimeUnit[] values ()
```

<br />

<br />

|                                           Returns                                           ||
|-------------------------------------------------------------------------------------|--------|
| [TimeUnit[]](https://developer.android.com/reference/java/util/concurrent/TimeUnit) | <br /> |