Java Number Format Pattern getNumberFormatter(final String format)

Here you can find the source of getNumberFormatter(final String format)

Description

get Number Formatter

License

Apache License

Declaration

private static DecimalFormat getNumberFormatter(final String format) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.text.DecimalFormat;

import java.util.Map;

import java.util.concurrent.ConcurrentHashMap;

public class Main {
    private static Map<String, ThreadLocal<DecimalFormat>> decimalFormatters = new ConcurrentHashMap<String, ThreadLocal<DecimalFormat>>();

    private static DecimalFormat getNumberFormatter(final String format) {
        ThreadLocal<DecimalFormat> threadLocal = decimalFormatters.get(format);
        if (threadLocal == null) {
            threadLocal = new ThreadLocal<DecimalFormat>() {
                @Override//from   w  ww  . ja  v a2 s  .  c o  m
                protected DecimalFormat initialValue() {
                    return new DecimalFormat(format);
                }
            };
            decimalFormatters.put(format, threadLocal);
        }
        return threadLocal.get();
    }
}

Related

  1. getNumberFormatter()
  2. getNumberOfDays(String year, String month)
  3. getNumberFormat(String localeStr)
  4. getNumber(final Map map, final Object key)
  5. getNumberFormatFromCache(Locale locale, Currency currency)
  6. getNumberStyleAsInt(String style)
  7. getNumberFormat(BigDecimal num, final int digits)
  8. getNumberComma(String number)
  9. getNumberFormat(String format, Locale locale)