From d0ddfa94025250db8d51a974450ad83990df2f7e Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 21 Nov 2017 21:11:07 +0000 Subject: [PATCH] remove more uses of Character.toUpperCase git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1815988 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/ss/format/CellDateFormatter.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/java/org/apache/poi/ss/format/CellDateFormatter.java b/src/java/org/apache/poi/ss/format/CellDateFormatter.java index 848a9e372c..375e1fbae3 100644 --- a/src/java/org/apache/poi/ss/format/CellDateFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellDateFormatter.java @@ -181,7 +181,6 @@ public class CellDateFormatter extends CellFormatter { boolean doneAm = false; boolean doneMillis = false; - it.first(); for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) { @@ -189,12 +188,9 @@ public class CellDateFormatter extends CellFormatter { if (!doneMillis) { Date dateObj = (Date) value; int pos = toAppendTo.length(); - Formatter formatter = new Formatter(toAppendTo, Locale.ROOT); - try { + try (Formatter formatter = new Formatter(toAppendTo, Locale.ROOT)) { long msecs = dateObj.getTime() % 1000; formatter.format(locale, sFmt, msecs / 1000.0); - } finally { - formatter.close(); } toAppendTo.delete(pos, pos + 2); doneMillis = true; @@ -203,11 +199,11 @@ public class CellDateFormatter extends CellFormatter { if (!doneAm) { if (showAmPm) { if (amPmUpper) { - toAppendTo.append(Character.toUpperCase(ch)); + toAppendTo.append(Character.toString(ch).toUpperCase(LocaleUtil.getUserLocale())); if (showM) toAppendTo.append('M'); } else { - toAppendTo.append(Character.toLowerCase(ch)); + toAppendTo.append(Character.toString(ch).toLowerCase(LocaleUtil.getUserLocale())); if (showM) toAppendTo.append('m'); }