From 6fbb02ef14a716cd882aaf87b6e87673826733a0 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Tue, 7 Jun 2016 08:54:08 +0000 Subject: [PATCH] add comments and make the statefulness of localeIsAdapting more obvious. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1747171 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/ss/usermodel/DataFormatter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java index 308445f9ca..6771207cc5 100644 --- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java +++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java @@ -207,7 +207,7 @@ public class DataFormatter implements Observer { private Locale locale; /** stores if the locale should change according to {@link LocaleUtil#getUserLocale()} */ - private boolean localeIsAdapting = true; + private boolean localeIsAdapting; private class LocaleChangeObservable extends Observable { void checkForLocaleChange() { @@ -265,8 +265,13 @@ public class DataFormatter implements Observer { * @param emulateCSV whether to emulate CSV output. */ private DataFormatter(Locale locale, boolean localeIsAdapting, boolean emulateCSV) { + this.localeIsAdapting = true; localeChangedObservable.addObserver(this); + // localeIsAdapting must be true prior to this first checkForLocaleChange call. localeChangedObservable.checkForLocaleChange(locale); + // set localeIsAdapting so subsequent checks perform correctly + // (whether a specific locale was provided to this DataFormatter or DataFormatter should + // adapt to the current user locale as the locale changes) this.localeIsAdapting = localeIsAdapting; this.emulateCSV = emulateCSV; } -- 2.39.5