mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix sax for date bug
This commit is contained in:
@@ -308,7 +308,7 @@ public class Excel03SaxReader extends AbstractExcelSaxReader<Excel03SaxReader> i
|
||||
value = numrec.getValue();
|
||||
} else if (formatString.contains(StrUtil.SLASH) || formatString.contains(StrUtil.COLON)) {
|
||||
//日期
|
||||
value = formatListener.formatNumberDateCell(numrec);
|
||||
value = ExcelSaxUtil.getDateValue(numrec.getValue());
|
||||
} else {
|
||||
final double doubleValue = numrec.getValue();
|
||||
final long longPart = (long) doubleValue;
|
||||
|
@@ -165,6 +165,17 @@ public class ExcelSaxUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期
|
||||
*
|
||||
* @param value 单元格值
|
||||
* @return 日期
|
||||
* @since 5.3.6
|
||||
*/
|
||||
public static DateTime getDateValue(String value) {
|
||||
return getDateValue(Double.parseDouble(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期
|
||||
*
|
||||
@@ -172,8 +183,8 @@ public class ExcelSaxUtil {
|
||||
* @return 日期
|
||||
* @since 4.1.0
|
||||
*/
|
||||
private static DateTime getDateValue(String value) {
|
||||
return DateUtil.date(org.apache.poi.ss.usermodel.DateUtil.getJavaDate(Double.parseDouble(value), false));
|
||||
public static DateTime getDateValue(double value) {
|
||||
return DateUtil.date(org.apache.poi.ss.usermodel.DateUtil.getJavaDate(value, false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -103,8 +103,9 @@ public class ExcelSaxReadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void dateReadTest(){
|
||||
ExcelUtil.readBySax("d:/test/sax_test.xls", 0, (RowHandler) (i, i1, list) ->
|
||||
ExcelUtil.readBySax("d:/test/sax_date_test.xlsx", 0, (i, i1, list) ->
|
||||
Console.log(StrUtil.join(", ", list)));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user