bug 60031: DataFormatter parses months incorrectly when put at the end of date segment. Thanks to Andrzej Witecki

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1779564 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2017-01-20 05:35:57 +00:00
parent c46e7d03f3
commit 9def800cd4
2 changed files with 15 additions and 0 deletions

View File

@ -582,6 +582,9 @@ public class DataFormatter implements Observer {
}
}
else {
if (Character.isWhitespace(c)){
ms.clear();
}
sb.append(c);
}
}

View File

@ -815,5 +815,17 @@ public class TestDataFormatter {
assertEquals("5.6789", formatter.formatCellValue(cell, evaluator));
wb.close();
}
/**
* bug 60031: DataFormatter parses months incorrectly when put at the end of date segment
*/
@Test
public void testBug60031() {
// 23-08-2016 08:51:01 which is 42605.368761574071 as double will be parsed
// with format "yyyy-dd-MM HH:mm:ss" into "2016-23-51 08:51:01".
DataFormatter dfUS = new DataFormatter(Locale.US);
assertEquals("2016-23-08 08:51:01", dfUS.formatRawCellContents(42605.368761574071, -1, "yyyy-dd-MM HH:mm:ss"));
assertEquals("2017-12-01 January 09:54:33", dfUS.formatRawCellContents(42747.412892397523, -1, "yyyy-dd-MM MMMM HH:mm:ss"));
}
}