Author: fanningpj
Date: Thu Feb 9 15:22:21 2023
New Revision: 1907543
URL: http://svn.apache.org/viewvc?rev=1907543&view=rev
Log:
DataFormatter - typo in javadoc and possible NPE
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1907543&r1=1907542&r2=1907543&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
(original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
Thu Feb 9 15:22:21 2023
@@ -99,7 +99,7 @@ import org.apache.poi.util.StringUtil;
* The trailing underscore and space ("_ ") in the format adds a space to the
end and Excel formats this cell as {@code "12.34 "},
* but {@code DataFormatter} trims the formatted value and returns {@code
"12.34"}.
* </p>
- * You can enable spaces by passing the {@code emulateCSV=true} flag in the
{@code DateFormatter} cosntructor.
+ * You can enable spaces by passing the {@code emulateCSV=true} flag in the
{@code DateFormatter} constructor.
* If set to true, then the output tries to conform to what you get when you
take an xls or xlsx in Excel and Save As CSV file:
* <ul>
* <li>returned values are not trimmed</li>
@@ -496,7 +496,11 @@ public class DataFormatter {
return generalNumberFormat;
}
- if(DateUtil.isADateFormat(formatIndex,formatStr) &&
+ if (formatStr == null) {
+ return null;
+ }
+
+ if(DateUtil.isADateFormat(formatIndex, formatStr) &&
DateUtil.isValidExcelDate(cellValue)) {
return createDateFormat(formatStr, cellValue);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]