mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add toEpochMilli
This commit is contained in:
parent
9eec8ec6e0
commit
c19f43837f
@ -9,6 +9,7 @@
|
||||
* 【core 】 StrUtil增加firstNonXXX方法(issue#1020@Github)
|
||||
* 【core 】 BeanCopier修改规则,可选bean拷贝空字段报错问题(pr#160@Gitee)
|
||||
* 【http 】 HttpUtil增加downloadFileFromUrl(pr#1023@Github)
|
||||
* 【core 】 增加toEpochMilli方法
|
||||
|
||||
### Bug修复#
|
||||
* 【poi 】 修复ExcelBase.isXlsx方法判断问题(issue#I1S502@Gitee)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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}对象
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user