TimeUnit Enum枚举
时间:2020-05-23
本文章向大家介绍TimeUnit Enum枚举,主要包括TimeUnit Enum枚举使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
所在包:
- All Implemented Interfaces:
- Serializable, Comparable<TimeUnit>
public enum TimeUnit
extends Enum<TimeUnit>
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.
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 Summary(枚举常量摘要)
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秒
|
Method Summary(方法总结)
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.
返回一个数组,该数组包含此枚举类型的常数,按其声明的顺序排列。
|
原文地址:https://www.cnblogs.com/LinQingYang/p/12943863.html
- 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](二)
- 怎么解决web service circular reference 问题
- android使用LruCache对listview加载图片时候优化处理
- 如何创建一个兼容「微信小程序」的Web框架:WIN
- RePractise前端篇: 前端演进史
- Git远程库版本回滚
- android 之ndk开发
- 【持续集成】使用 Jenkinsfile 设计直观的 Pipeline
- 将OpenOffice.org变成一个文档格式转换工具
- 客户端的web技术
- unwx:一个解压微信小程序的命令 、微信小程序是如何压缩的
- 我的第四款编辑器:微信公众号上使用 Markdown 来显示代码
- 将Quartz.NET集成到 Castle中
- listview滑动删除
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法