Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public enum TimeUnit
- Object
- Enum<TimeUnit>
- TimeUnit
ImplementsComparable<TimeUnit>
A unit of time, for timeouts such as
Future.get(long, TimeUnit). Conversions
saturate: a value too large for the target unit becomes Long.MAX_VALUE or
Long.MIN_VALUE rather than overflowing.Enum constants
NANOSECONDS | Billionths of a second. |
MICROSECONDS | Millionths of a second. |
MILLISECONDS | Thousandths of a second. |
SECONDS | Seconds. |
MINUTES | Minutes. |
HOURS | Hours. |
DAYS | Days. |
Methods
public static TimeUnit[] values() | |
public static TimeUnit valueOf(String name) | |
public long convert(long sourceDuration, TimeUnit sourceUnit) | sourceDuration in sourceUnit, converted to this unit. |
public long toNanos(long d) | d of this unit in nanoseconds. |
public long toMicros(long d) | d of this unit in microseconds. |
public long toMillis(long d) | d of this unit in milliseconds. |
public long toSeconds(long d) | d of this unit in seconds. |
public long toMinutes(long d) | d of this unit in minutes. |
public long toHours(long d) | d of this unit in hours. |
public long toDays(long d) | d of this unit in days. |
public void timedWait(Object obj, long timeout)
throws InterruptedException | Waits on obj for timeout of this unit, as obj.wait does. |
public void timedJoin(Thread thread, long timeout)
throws InterruptedException | Waits up to timeout of this unit for thread to end, as thread.join does. |
public void sleep(long timeout)
throws InterruptedException | Sleeps for timeout of this unit, as Thread.sleep does. |
Inherited methods
Enum constant details
NANOSECONDS
NANOSECONDSBillionths of a second.
MICROSECONDS
MICROSECONDSMillionths of a second.
MILLISECONDS
MILLISECONDSThousandths of a second.
SECONDS
SECONDSSeconds.
MINUTES
MINUTESMinutes.
HOURS
HOURSHours.
DAYS
DAYSDays.
Method details
values
public static TimeUnit[] values()valueOf
public static TimeUnit valueOf(String name)convert
public long convert(long sourceDuration, TimeUnit sourceUnit)sourceDuration in sourceUnit, converted to this unit.Parameters
sourceDurationlong- the duration
sourceUnitTimeUnit- its unit
Returns
the duration in this unit
toNanos
public long toNanos(long d)d of this unit in nanoseconds.Parameters
dlong- the duration
Returns
the converted duration
toMicros
public long toMicros(long d)d of this unit in microseconds.Parameters
dlong- the duration
Returns
the converted duration
toMillis
public long toMillis(long d)d of this unit in milliseconds.Parameters
dlong- the duration
Returns
the converted duration
toSeconds
public long toSeconds(long d)d of this unit in seconds.Parameters
dlong- the duration
Returns
the converted duration
toMinutes
public long toMinutes(long d)d of this unit in minutes.Parameters
dlong- the duration
Returns
the converted duration
toHours
public long toHours(long d)d of this unit in hours.Parameters
dlong- the duration
Returns
the converted duration
toDays
public long toDays(long d)d of this unit in days.Parameters
dlong- the duration
Returns
the converted duration
timedWait
public void timedWait(Object obj, long timeout)
throws InterruptedExceptionWaits on
obj for timeout of this unit, as obj.wait does.Parameters
objObject- the monitor, which the caller must hold
timeoutlong- how long to wait
Throws
InterruptedException- when the thread is interrupted
timedJoin
public void timedJoin(Thread thread, long timeout)
throws InterruptedExceptionWaits up to
timeout of this unit for thread to end, as thread.join does.Parameters
threadThread- the thread to wait for
timeoutlong- how long to wait
Throws
InterruptedException- when the waiting thread is interrupted
sleep
public void sleep(long timeout)
throws InterruptedExceptionSleeps for
timeout of this unit, as Thread.sleep does.Parameters
timeoutlong- how long to sleep
Throws
InterruptedException- when the thread is interrupted