mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -3,6 +3,7 @@ package cn.hutool.core.convert.impl;
|
||||
import cn.hutool.core.convert.AbstractConverter;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.format.GlobalCustomFormat;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
|
||||
@@ -156,7 +157,15 @@ public class TemporalAccessorConverter extends AbstractConverter {
|
||||
return IsoEra.of(Math.toIntExact(time));
|
||||
}
|
||||
|
||||
return parseFromInstant(targetClass, Instant.ofEpochMilli(time), null);
|
||||
final Instant instant;
|
||||
if(GlobalCustomFormat.FORMAT_SECONDS.equals(this.format)){
|
||||
// https://gitee.com/dromara/hutool/issues/I6IS5B
|
||||
// Unix时间戳
|
||||
instant = Instant.ofEpochSecond(time);
|
||||
}else{
|
||||
instant = Instant.ofEpochMilli(time);
|
||||
}
|
||||
return parseFromInstant(targetClass, instant, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,13 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class GlobalCustomFormat {
|
||||
|
||||
/**
|
||||
* 格式:秒时间戳(Unix时间戳)
|
||||
*/
|
||||
public static final String FORMAT_SECONDS = "#sss";
|
||||
/**
|
||||
* 格式:毫秒时间戳
|
||||
*/
|
||||
public static final String FORMAT_MILLISECONDS = "#SSS";
|
||||
|
||||
private static final Map<CharSequence, Function<Date, String>> formatterMap;
|
||||
|
Reference in New Issue
Block a user