mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix bug
This commit is contained in:
parent
a54ce406b7
commit
394d05f9d2
@ -11,6 +11,7 @@
|
||||
|
||||
### Bug修复
|
||||
* 【core 】 修复DateUtil.current使用System.nanoTime的问题(issue#1198@Github)
|
||||
* 【core 】 修复Excel03SaxReader判断日期出错问题(issue#I23M9H@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -648,10 +648,6 @@ public class DateTime extends Date {
|
||||
return new Date(this.getTime());
|
||||
}
|
||||
|
||||
public Date writeReplace(){
|
||||
return toJdkDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转为{@link Timestamp}
|
||||
*
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.hutool.poi.excel.sax;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -306,11 +305,9 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader<Excel03Sax
|
||||
break;
|
||||
case NumberRecord.sid: // 数字类型
|
||||
final NumberRecord numrec = (NumberRecord) record;
|
||||
final String formatString = formatListener.getFormatString(numrec);
|
||||
if(false == StrUtil.contains(formatString, '%') &&
|
||||
false == "General".equalsIgnoreCase(formatString)){
|
||||
if(ExcelSaxUtil.isDateFormat(numrec, formatListener)){
|
||||
// 可能为日期格式
|
||||
value = DateUtil.date(org.apache.poi.ss.usermodel.DateUtil.getJavaDate(numrec.getValue()));
|
||||
value = ExcelSaxUtil.getDateValue(numrec.getValue());
|
||||
} else {
|
||||
final double doubleValue = numrec.getValue();
|
||||
final long longPart = (long) doubleValue;
|
||||
|
@ -7,6 +7,8 @@ import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||
import cn.hutool.poi.exceptions.POIException;
|
||||
import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener;
|
||||
import org.apache.poi.hssf.record.NumberRecord;
|
||||
import org.apache.poi.ooxml.util.SAXHelper;
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.xssf.model.SharedStringsTable;
|
||||
@ -171,6 +173,19 @@ public class ExcelSaxUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数字Record中是否为日期格式
|
||||
* @param numrec 单元格记录
|
||||
* @param formatListener {@link FormatTrackingHSSFListener}
|
||||
* @return 是否为日期格式
|
||||
* @since 5.4.8
|
||||
*/
|
||||
public static boolean isDateFormat(NumberRecord numrec, FormatTrackingHSSFListener formatListener){
|
||||
final int formatIndex = formatListener.getFormatIndex(numrec);
|
||||
final String formatString = formatListener.getFormatString(numrec);
|
||||
return org.apache.poi.ss.usermodel.DateUtil.isADateFormat(formatIndex, formatString);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user