add toEpochMilli

This commit is contained in:
Looly 2020-08-20 17:14:42 +08:00
parent 9eec8ec6e0
commit c19f43837f
3 changed files with 24 additions and 0 deletions

View File

@ -9,6 +9,7 @@
* 【core 】 StrUtil增加firstNonXXX方法issue#1020@Github
* 【core 】 BeanCopier修改规则可选bean拷贝空字段报错问题pr#160@Gitee
* 【http 】 HttpUtil增加downloadFileFromUrlpr#1023@Github
* 【core 】 增加toEpochMilli方法
### Bug修复#
* 【poi 】 修复ExcelBase.isXlsx方法判断问题issue#I1S502@Gitee

View File

@ -415,4 +415,16 @@ public class LocalDateTimeUtil {
public static LocalDateTime endOfDay(LocalDateTime time) {
return time.with(LocalTime.of(23, 59, 59, 999_999_999));
}
/**
* {@link TemporalAccessor}转换为 时间戳从1970-01-01T00:00:00Z开始的毫秒数
*
* @param temporalAccessor Date对象
* @return {@link Instant}对象
* @since 5.4.1
* @see TemporalAccessorUtil#toEpochMilli(TemporalAccessor)
*/
public static long toEpochMilli(TemporalAccessor temporalAccessor) {
return TemporalAccessorUtil.toEpochMilli(temporalAccessor);
}
}

View File

@ -76,6 +76,17 @@ public class TemporalAccessorUtil {
return format(time, formatter);
}
/**
* {@link TemporalAccessor}转换为 时间戳从1970-01-01T00:00:00Z开始的毫秒数
*
* @param temporalAccessor Date对象
* @return {@link Instant}对象
* @since 5.4.1
*/
public static long toEpochMilli(TemporalAccessor temporalAccessor) {
return toInstant(temporalAccessor).toEpochMilli();
}
/**
* {@link TemporalAccessor}转换为 {@link Instant}对象
*