From bf979f253446f41e29869f7b36c129d3e63759b9 Mon Sep 17 00:00:00 2001 From: Looly Date: Sun, 4 Jan 2026 18:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`DateUnit`=E6=AF=AB=E7=A7=92?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98=EF=BC=88issue#4209@Github?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + hutool-core/src/main/java/cn/hutool/core/date/DateUnit.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e5eae6a9..52472dafa3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ * 【core 】 修复`Calculator.conversion`方法计算包含%连接一元运算符的计算表达式的结果时逻辑缺陷(pr#4191@Github) * 【db 】 修复`SqlUtil.PATTERN_IN_CLAUSE`逻辑缺陷导致in语句参数不正确的问题(pr#4203@Github) * 【json 】 修复`ObjectMapper`过滤器对Bean复制无效的问题(pr#1431@Gitee) +* 【core 】 修复`DateUnit`毫秒转换问题(issue#4209@Github) ------------------------------------------------------------------------------------------------------------- # 5.8.42(2025-11-28) diff --git a/hutool-core/src/main/java/cn/hutool/core/date/DateUnit.java b/hutool-core/src/main/java/cn/hutool/core/date/DateUnit.java index 17388cb909..81850e03a4 100644 --- a/hutool-core/src/main/java/cn/hutool/core/date/DateUnit.java +++ b/hutool-core/src/main/java/cn/hutool/core/date/DateUnit.java @@ -65,7 +65,7 @@ public enum DateUnit { */ public static DateUnit of(ChronoUnit unit) { switch (unit) { - case MICROS: + case MILLIS: return DateUnit.MS; case SECONDS: return DateUnit.SECOND; @@ -91,7 +91,7 @@ public enum DateUnit { public static ChronoUnit toChronoUnit(DateUnit unit) { switch (unit) { case MS: - return ChronoUnit.MICROS; + return ChronoUnit.MILLIS; case SECOND: return ChronoUnit.SECONDS; case MINUTE: