From: PJ Fanning Date: Wed, 28 Jul 2021 20:15:11 +0000 (+0000) Subject: [bug-65471] fix DataFormatter so it can handle Ts (ISO 8601) X-Git-Tag: REL_5_1_0~104 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=abe513199715dd4639514638bce9555f7e243308;p=poi.git [bug-65471] fix DataFormatter so it can handle Ts (ISO 8601) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891864 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestText.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestText.java index df8aa2379d..07680b7d54 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestText.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestText.java @@ -101,17 +101,24 @@ final class TestText { ValueEval numArg = new NumberEval(321.321); ValueEval formatArg = new StringEval("dd:MM:yyyy hh:mm:ss"); ValueEval[] args = { numArg, formatArg }; - ValueEval result = TextFunction.TEXT.evaluate(args, -1, (short)-1); + ValueEval result = TextFunction.TEXT.evaluate(args, -1, -1); ValueEval testResult = new StringEval("16:11:1900 07:42:14"); assertEquals(testResult.toString(), result.toString()); // Excel also supports "m before h is month" formatArg = new StringEval("dd:mm:yyyy hh:mm:ss"); args[1] = formatArg; - result = TextFunction.TEXT.evaluate(args, -1, (short)-1); + result = TextFunction.TEXT.evaluate(args, -1, -1); testResult = new StringEval("16:11:1900 07:42:14"); assertEquals(testResult.toString(), result.toString()); + // Excel also supports ".SSS" + formatArg = new StringEval("dd:mm:yyyy hh:mm:ss.SSS"); + args[1] = formatArg; + result = TextFunction.TEXT.evaluate(args, -1, -1); + testResult = new StringEval("16:11:1900 07:42:14.014"); + assertEquals(testResult.toString(), result.toString()); + // this line is intended to compute how "November" would look like in the current locale // update: now the locale will be (if not set otherwise) always Locale.getDefault() (see LocaleUtil) DateFormatSymbols dfs = DateFormatSymbols.getInstance(LocaleUtil.getUserLocale()); @@ -150,7 +157,7 @@ final class TestText { formatArg = new StringEval("yyyy-mm-ddThh:MM:ss.000"); args[1] = formatArg; result = TextFunction.TEXT.evaluate(args, -1, -1); - testResult = new StringEval("16:11:1900 07:42:14.400"); + testResult = new StringEval("1900-11-16T07:42:14.400"); assertEquals(testResult.toString(), result.toString()); }