Java Decimal Format getDecimalFormat()

Here you can find the source of getDecimalFormat()

Description

get Decimal Format

License

Open Source License

Return

A thread-local formatter instance set to parse numbers into BigDecimals.

Declaration

static DecimalFormat getDecimalFormat() 

Method Source Code

//package com.java2s;
/**//  www  .ja v a 2s. co  m
 * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */

import java.text.DecimalFormat;

public class Main {
    /** Formatter for decimal numbers, DecimalFormat isn't thread safe. */
    private static final ThreadLocal<DecimalFormat> s_decimalFormat = new ThreadLocal<DecimalFormat>() {
        @Override
        protected DecimalFormat initialValue() {
            DecimalFormat decimalFormat = new DecimalFormat("#,###.#####");
            decimalFormat.setParseBigDecimal(true);
            return decimalFormat;
        }
    };

    /**
     * @return A thread-local formatter instance set to parse numbers into BigDecimals.
     */
    /* package */static DecimalFormat getDecimalFormat() {
        return s_decimalFormat.get();
    }
}

Related

  1. decimalString(double d, boolean forceDigits)
  2. encodeDouble(double d)
  3. getCorrectionValue(double basicValue, int digit)
  4. getDecimalFormat()
  5. getDecimalFormat()
  6. getDecimalFormat()
  7. getDecimalFormat(final int decimalPlaces)
  8. getDecimalFormat(int decimalPlaces, Locale locale)
  9. getDecimalFormat(int precision)