From 7b8546e4e5a5a78f4020d98f4634a0e631df07e3 Mon Sep 17 00:00:00 2001 From: khw <11910710@mail.sustech.edu.cn> Date: Sun, 24 Apr 2022 23:03:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86javadoc=E5=92=8C?= =?UTF-8?q?=E5=AF=B9method=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/alibaba/excel/util/NumberUtils.java | 8 +++---- .../test/temp/issue2443/Issue2443Test.java | 22 ++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/alibaba/excel/util/NumberUtils.java b/src/main/java/com/alibaba/excel/util/NumberUtils.java index a5f1c512..d52a3299 100644 --- a/src/main/java/com/alibaba/excel/util/NumberUtils.java +++ b/src/main/java/com/alibaba/excel/util/NumberUtils.java @@ -95,11 +95,11 @@ public class NumberUtils { } /** - * parse + * parse Integer from string * - * @param string - * @param contentProperty - * @return + * @param string An integer read in string format + * @param contentProperty Properties of the content read in + * @return An integer converted from a string */ public static Integer parseInteger(String string, ExcelContentProperty contentProperty) throws ParseException { if (!hasFormat(contentProperty)) { diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/issue2443/Issue2443Test.java b/src/test/java/com/alibaba/easyexcel/test/temp/issue2443/Issue2443Test.java index 4695f293..57484b74 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/issue2443/Issue2443Test.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/issue2443/Issue2443Test.java @@ -1,14 +1,17 @@ package com.alibaba.easyexcel.test.temp.issue2443; import com.alibaba.easyexcel.test.util.TestFileUtil; +import com.alibaba.excel.metadata.property.ExcelContentProperty; +import com.alibaba.excel.util.NumberUtils; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.read.listener.PageReadListener; import com.alibaba.fastjson.JSON; import lombok.extern.slf4j.Slf4j; import org.junit.Ignore; import org.junit.Test; - +import static org.junit.Assert.*; import java.io.File; +import java.text.ParseException; @Ignore @Slf4j @@ -33,4 +36,21 @@ public class Issue2443Test { } })).sheet().doRead(); } + + @Test + public void parseIntegerTest1() throws ParseException { + String string = "1.00"; + ExcelContentProperty contentProperty = null; + int Int = NumberUtils.parseInteger(string,contentProperty); + assertEquals(1, Int); + } + + @Test + public void parseIntegerTest2() throws ParseException { + String string = "2.00"; + ExcelContentProperty contentProperty = null; + int Int = NumberUtils.parseInteger(string,contentProperty); + assertEquals(2, Int); + } + }