public class TemporalUtil extends Object
Temporal
工具类封装Constructor and Description |
---|
TemporalUtil() |
Modifier and Type | Method and Description |
---|---|
static Duration |
between(Temporal startTimeInclude,
Temporal endTimeExclude)
获取两个日期的差,如果结束时间早于开始时间,获取结果为负。
|
static long |
between(Temporal startTimeInclude,
Temporal endTimeExclude,
ChronoUnit unit)
获取两个日期的差,如果结束时间早于开始时间,获取结果为负。
|
public static Duration between(Temporal startTimeInclude, Temporal endTimeExclude)
返回结果为Duration
对象,通过调用toXXX方法返回相差单位
startTimeInclude
- 开始时间(包含)endTimeExclude
- 结束时间(不包含)Duration
对象public static long between(Temporal startTimeInclude, Temporal endTimeExclude, ChronoUnit unit)
返回结果为时间差的long值
startTimeInclude
- 开始时间(包括)endTimeExclude
- 结束时间(不包括)unit
- 时间差单位Copyright © 2021. All rights reserved.