From c5911c05011245270d397e383cf8b8a3091e2a53 Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 30 Aug 2022 21:53:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8F=90=E7=A4=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../test/java/cn/hutool/core/date/ZodiacTest.java | 15 +++++++++++++++ .../java/cn/hutool/core/date/ZoneUtilTest.java | 15 +++++++++++++++ .../hutool/poi/excel/reader/MapSheetReader.java | 4 +++- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 hutool-core/src/test/java/cn/hutool/core/date/ZoneUtilTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 06ab1fb18..106f3d78c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ * 【core 】 修复zip被识别成jar和apk被识别成jar或zip的问题(pr#2548@Github) * 【core 】 修复UrlBuilder.addPath 方法传入非有效路径字符串时,会出现空指针异常的问题(issue#I5O4ML@Gitee) * 【core 】 修复FilterIter当参数filter为空时存在问题(issue#I5OG7U@Gitee) +* 【poi 】 修复Excel读取提示信息错误(issue#I5OSFC@Gitee) ------------------------------------------------------------------------------------------------------------- diff --git a/hutool-core/src/test/java/cn/hutool/core/date/ZodiacTest.java b/hutool-core/src/test/java/cn/hutool/core/date/ZodiacTest.java index dac1329c3..91ea2f884 100644 --- a/hutool-core/src/test/java/cn/hutool/core/date/ZodiacTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/date/ZodiacTest.java @@ -3,6 +3,8 @@ package cn.hutool.core.date; import org.junit.Assert; import org.junit.Test; +import java.util.Calendar; + public class ZodiacTest { @Test @@ -10,6 +12,12 @@ public class ZodiacTest { Assert.assertEquals("摩羯座", Zodiac.getZodiac(Month.JANUARY, 19)); Assert.assertEquals("水瓶座", Zodiac.getZodiac(Month.JANUARY, 20)); Assert.assertEquals("巨蟹座", Zodiac.getZodiac(6, 17)); + + final Calendar calendar = Calendar.getInstance(); + calendar.set(2022, Calendar.JULY, 17); + Assert.assertEquals("巨蟹座", Zodiac.getZodiac(calendar.getTime())); + Assert.assertEquals("巨蟹座", Zodiac.getZodiac(calendar)); + Assert.assertNull(Zodiac.getZodiac((Calendar) null)); } @Test @@ -17,5 +25,12 @@ public class ZodiacTest { Assert.assertEquals("狗", Zodiac.getChineseZodiac(1994)); Assert.assertEquals("狗", Zodiac.getChineseZodiac(2018)); Assert.assertEquals("猪", Zodiac.getChineseZodiac(2019)); + + final Calendar calendar = Calendar.getInstance(); + calendar.set(2022, Calendar.JULY, 17); + Assert.assertEquals("虎", Zodiac.getChineseZodiac(calendar.getTime())); + Assert.assertEquals("虎", Zodiac.getChineseZodiac(calendar)); + Assert.assertNull(Zodiac.getChineseZodiac(1899)); + Assert.assertNull(Zodiac.getChineseZodiac((Calendar) null)); } } diff --git a/hutool-core/src/test/java/cn/hutool/core/date/ZoneUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/date/ZoneUtilTest.java new file mode 100755 index 000000000..b7399645a --- /dev/null +++ b/hutool-core/src/test/java/cn/hutool/core/date/ZoneUtilTest.java @@ -0,0 +1,15 @@ +package cn.hutool.core.date; + +import org.junit.Assert; +import org.junit.Test; + +import java.time.ZoneId; +import java.util.TimeZone; + +public class ZoneUtilTest { + @Test + public void toTest() { + Assert.assertEquals(ZoneId.systemDefault(), ZoneUtil.toZoneId(null)); + Assert.assertEquals(TimeZone.getDefault(), ZoneUtil.toTimeZone(null)); + } +} diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java index 0f832597d..11aebaea0 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java @@ -44,7 +44,9 @@ public class MapSheetReader extends AbstractSheetReader if (headerRowIndex < firstRowNum) { throw new IndexOutOfBoundsException(StrUtil.format("Header row index {} is lower than first row index {}.", headerRowIndex, firstRowNum)); } else if (headerRowIndex > lastRowNum) { - throw new IndexOutOfBoundsException(StrUtil.format("Header row index {} is greater than last row index {}.", headerRowIndex, firstRowNum)); + throw new IndexOutOfBoundsException(StrUtil.format("Header row index {} is greater than last row index {}.", headerRowIndex, lastRowNum)); + } else if (startRowIndex > lastRowNum) { + throw new IndexOutOfBoundsException(StrUtil.format("startRowIndex row index {} is greater than last row index {}.", startRowIndex, lastRowNum)); } final int startRowIndex = Math.max(this.startRowIndex, firstRowNum);// 读取起始行(包含) final int endRowIndex = Math.min(this.endRowIndex, lastRowNum);// 读取结束行(包含)