Closed dasoops closed 2 months ago
JDK版本:
java version "17.0.3.1" 2022-04-22 LTS Java(TM) SE Runtime Environment (build 17.0.3.1+2-LTS-6) Java HotSpot(TM) 64-Bit Server VM (build 17.0.3.1+2-LTS-6, mixed mode, sharing)
hutool版本: 5.8.27(请确保最新尝试是否还有问题)
<!-- pom.xml --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.8.27</version> </dependency>
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.format.FastDateFormat; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.text.SimpleDateFormat; import java.util.TimeZone; public class FastDateFormatTest { private static final TimeZone timezone = TimeZone.getTimeZone("Etc/Utc"); private static FastDateFormat getHutoolInstance(String pattern) { return FastDateFormat.getInstance(pattern, timezone); } @Test public void test() { var date = DateUtil.date(0L); Assertions.assertEquals( getHutoolInstance("yyyy-MM-dd HH:mm:ss").format(date), "1970-01-01 00:00:00" ); Assertions.assertEquals( getHutoolInstance("YYYY-MM-dd HH:mm:ss").format(date), "1970-01-01 00:00:00" ); Assertions.assertEquals( getHutoolInstance("YYYY").format(date), "1970" ); Assertions.assertEquals( getHutoolInstance("yy").format(date), "70" ); Assertions.assertEquals( new SimpleDateFormat("YY").format(date), "70" ); // org.opentest4j.AssertionFailedError: // Expected :õ0 // Actual :70 Assertions.assertEquals( getHutoolInstance("YY").format(date), "70" ); } }
TwoDigitYearField.appendTo(Appendable, int)
TwoDigitYearField.appendTo(Appendable, Calendar)
感谢给出详细的说明
5.8.29修复此问题~~
版本情况
JDK版本:
hutool版本: 5.8.27(请确保最新尝试是否还有问题)
问题描述(包括截图)
TwoDigitYearField.appendTo(Appendable, int)
, 没有经过TwoDigitYearField.appendTo(Appendable, Calendar)
850行的取余操作 https://github.com/dromara/hutool/blob/38592915eb1e599fdd9a2ba66881b19dcdff7ee6/hutool-core/src/main/java/cn/hutool/core/date/format/FastDatePrinter.java#L1039-L1042 https://github.com/dromara/hutool/blob/38592915eb1e599fdd9a2ba66881b19dcdff7ee6/hutool-core/src/main/java/cn/hutool/core/date/format/FastDatePrinter.java#L845-L859