标签:fine convert odi mat var mem available follow font
所在包:
public enum TimeUnit
extends Enum<TimeUnit>
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.TimeUnit
does not maintain time information, but only helps organize and use time representations that may be maintained separately across various contexts.TimeUnit
表示给定单元粒度的时间段,并提供实用程序方法来跨单元转换,以及在这些单元中执行计时和延迟操作。TimeUnit
不维护时间信息,但只帮助组织和使用可能在不同上下文中单独维护的时间表示。微秒为千分之一毫秒,
毫秒为千分之一秒,
一分钟为六十秒,
一小时为六十分钟,
一天为二十四小时。
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
is not available:
时间单元主要用于通知基于时间的方法如何解释给定的时间参数。例如,如果锁不可用,下面的代码将在50毫秒内超时:
public enum Lock lock = ...;
if (lock.tryLock(50L, TimeUnit.MILLISECONDS)) ...
while this code will timeout in 50 seconds:
而这段代码将在50秒内超时:
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
.
但是请注意,并不能保证特定的超时实现能够注意到与给定时间单位相同粒度的时间流逝。
Since:
1.5
Enum Constant and Description 枚举常量和描述 |
---|
DAYS
Time unit representing twenty four hours
天时间单元代表24小时
|
HOURS
Time unit representing sixty minutes
小时时间单元代表60分钟
|
MICROSECONDS
Time unit representing one thousandth of a millisecond
微秒时间单元代表千分之一毫秒
|
MILLISECONDS
Time unit representing one thousandth of a second
毫秒时间单元代表千分之一秒
|
MINUTES
Time unit representing sixty seconds
分钟时间单元代表60秒
|
NANOSECONDS
Time unit representing one thousandth of a microsecond
纳秒时间单元代表千分之一微秒
|
SECONDS
Time unit representing one second
时间单元代表1秒
|
Modifier and Type 修饰符和类型 |
Method and Description 方法描述 |
---|---|
long |
convert(long sourceDuration, TimeUnit sourceUnit)
Converts the given time duration in the given unit to this unit.
将给定单元中的给定持续时间转换为此单元。
|
void |
sleep(long timeout)
Performs a
Thread.sleep using this time unit.使用这个时间单位执行
Thread.sleep线程休眠。 |
void |
timedJoin(Thread thread, long timeout)
Performs a timed
Thread.join using this time unit.使用这个时间单位执行一次
Thread.join。 |
void |
timedWait(Object obj, long timeout)
Performs a timed
Object.wait using this time unit. |
long |
toDays(long duration)
Equivalent to
DAYS.convert(duration, this) . |
long |
toHours(long duration)
Equivalent to
HOURS.convert(duration, this) . |
long |
toMicros(long duration)
Equivalent to
MICROSECONDS.convert(duration, this) . |
long |
toMillis(long duration)
Equivalent to
MILLISECONDS.convert(duration, this) . |
long |
toMinutes(long duration)
Equivalent to
MINUTES.convert(duration, this) . |
long |
toNanos(long duration)
Equivalent to
NANOSECONDS.convert(duration, this) . |
long |
toSeconds(long duration)
Equivalent to
SECONDS.convert(duration, this) . |
static TimeUnit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
返回具有指定名称的此类型的枚举常量。
|
static TimeUnit[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared.
返回一个数组,该数组包含此枚举类型的常数,按其声明的顺序排列。
|
标签:fine convert odi mat var mem available follow font
原文地址:https://www.cnblogs.com/LinQingYang/p/12943863.html