Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.LoggerFactory;

Expand All @@ -66,7 +64,7 @@ public class ConversionUtils
private static final int STYLE_INTEGER = 4;

// cache custom formats
private static ConcurrentMap<String,NumberFormat> customFormatsCache = new ConcurrentHashMap<String,NumberFormat>();
private static final ThreadLocal<Map<String, NumberFormat>> CUSTOM_FORMATS_CACHE = ThreadLocal.withInitial(HashMap::new);

private ConversionUtils() {}

Expand Down Expand Up @@ -102,11 +100,11 @@ public static NumberFormat getNumberFormat(String format, Locale locale)
{
// we have a custom format
String cacheKey = format + "%" + locale.toString();
nf = customFormatsCache.get(cacheKey);
nf = CUSTOM_FORMATS_CACHE.get().get(cacheKey);
if( nf == null )
{
nf = new DecimalFormat(format, new DecimalFormatSymbols(locale));
customFormatsCache.put(cacheKey,nf);
CUSTOM_FORMATS_CACHE.get().put(cacheKey,nf);
}
}
else
Expand Down