TimeUnit Class

Definition

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.

[Android.Runtime.Register("java/util/concurrent/TimeUnit", DoNotGenerateAcw=true)]
public sealed class TimeUnit : Java.Lang.Enum
[<Android.Runtime.Register("java/util/concurrent/TimeUnit", DoNotGenerateAcw=true)>]
type TimeUnit = class
    inherit Enum
Inheritance
TimeUnit
Attributes

Remarks

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 java.util.concurrent.locks.Lock lock is not available:

{@code
            Lock lock = ...;
            if (lock.tryLock(50L, TimeUnit.MILLISECONDS)) ...}

while this code will timeout in 50 seconds:

{@code
            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.

Added in 1.5.

Java documentation for java.util.concurrent.TimeUnit.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Days

Time unit representing twenty four hours

DeclaringClass

Returns the Class object corresponding to this enum constant's enum type.

(Inherited from Enum)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
Hours

Time unit representing sixty minutes

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Microseconds

Time unit representing one thousandth of a millisecond

Milliseconds

Time unit representing one thousandth of a second

Minutes

Time unit representing sixty seconds

Nanoseconds

Time unit representing one thousandth of a microsecond

PeerReference (Inherited from Object)
Seconds

Time unit representing one second

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Enum)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Enum)

Methods

Clone()

Throws CloneNotSupportedException.

(Inherited from Enum)
CompareTo(Object)

Compares this enum with the specified object for order.

(Inherited from Enum)
Convert(Duration)

Converts the given time duration to this unit.

Convert(Int64, TimeUnit)

Converts the given time duration in the given unit to this unit.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Returns true if the specified object is equal to this enum constant.

(Inherited from Enum)
GetHashCode()

Returns a hash code for this enum constant.

(Inherited from Enum)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Name()

Returns the name of this enum constant, exactly as declared in its enum declaration.

(Inherited from Enum)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Ordinal()

Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).

(Inherited from Enum)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
Sleep(Int64)

Performs a Thread#sleep(long, int) Thread.sleep using this time unit.

TimedJoin(Thread, Int64)

Performs a timed Thread#join(long, int) Thread.join using this time unit.

TimedWait(Object, Int64)

Performs a timed Object#wait(long, int) Object.wait using this time unit.

ToArray<T>() (Inherited from Object)
ToDays(Int64)

Equivalent to #convert(long, TimeUnit) DAYS.convert(duration, this).

ToHours(Int64)

Equivalent to #convert(long, TimeUnit) HOURS.convert(duration, this).

ToMicros(Int64)

Equivalent to #convert(long, TimeUnit) MICROSECONDS.convert(duration, this).

ToMillis(Int64)

Equivalent to #convert(long, TimeUnit) MILLISECONDS.convert(duration, this).

ToMinutes(Int64)

Equivalent to #convert(long, TimeUnit) MINUTES.convert(duration, this).

ToNanos(Int64)

Equivalent to #convert(long, TimeUnit) NANOSECONDS.convert(duration, this).

ToSeconds(Int64)

Equivalent to #convert(long, TimeUnit) SECONDS.convert(duration, this).

ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
ValueOf(String)
Values()
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to