public class DateCalculateUtils extends Object
| 构造器和说明 |
|---|
DateCalculateUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
getDayDiff(Date startDate,
Date endDate)
计算两个时间相差天数
注意:其他更小的单位不参与计算
例:昨天 23:59:00 与 今天 00:00:01 的计算结果为 1
|
static long |
getFullDayDiff(Date startDate,
Date endDate)
计算两个时间相差天数
完整计算,不足1天则忽略
|
static long |
getFullHourDiff(Date startDate,
Date endDate)
计算两个时间相差小时数
完整计算,不足1小时则忽略
|
static long |
getFullMinDiff(Date startDate,
Date endDate)
计算两个时间相差分钟数
完整计算,不足1分钟则忽略
|
static long |
getFullMonthDiff(Date startDate,
Date endDate)
计算两个时间相差月数
完整计算,不足1月则忽略
|
static long |
getFullSecDiff(Date startDate,
Date endDate)
计算两个时间相差秒数
完整计算,不足1秒则忽略
|
static long |
getFullWeekDiff(Date startDate,
Date endDate)
计算两个时间相差周数
完整计算,不足1周则忽略
|
static long |
getFullYearDiff(Date startDate,
Date endDate)
计算两个时间相差年数
完整计算,不足1年则忽略
|
static long |
getMonthDiff(Date startDate,
Date endDate)
计算两个时间相差月数
注意:其他更小的单位不参与计算
例:2022-04-30 与 2022-05-01 的计算结果为 1
|
static long |
getYearDiff(Date startDate,
Date endDate)
计算两个时间相差年数
注意:其他更小的单位不参与计算
例:2022-12-29 与 2023-01-01 的计算结果为 1
|
public static long getDayDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getMonthDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getYearDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getFullSecDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getFullMinDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getFullHourDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getFullDayDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getFullWeekDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间public static long getFullMonthDiff(Date startDate, Date endDate)
startDate - 开始时间endDate - 结束时间Copyright © 2023 EFCloud. All rights reserved.