mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix sax for date bug
This commit is contained in:
parent
5a99c64226
commit
640312c745
@ -36,7 +36,8 @@
|
||||
### Bug修复
|
||||
* 【core 】 修复SimpleCache死锁问题(issue#I1HOKB@Gitee)
|
||||
* 【core 】 修复SemaphoreRunnable释放问题(issue#I1HLQQ@Gitee)
|
||||
* 【poi 】 修复Sax方式读取Excel行号错误问题(issue#882@Gitee)
|
||||
* 【poi 】 修复Sax方式读取Excel行号错误问题(issue#882@Github)
|
||||
* 【poi 】 修复Sax方式读取Excel日期类型数据03和07不一致问题(issue#I1HL1C@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -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)));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user