Returns a thousands separated decimal formatter. - Java java.lang

Java examples for java.lang:double Format

Description

Returns a thousands separated decimal formatter.

Demo Code


//package com.java2s;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;

public class Main {
    /**//  www  . j a va 2s.co  m
     * Returns a thousands separated decimal formatter.
     *
     * @return
     */
    public static DecimalFormat getThousandSeperatedDecimalFormat() {
        DecimalFormat df = (DecimalFormat) NumberFormat
                .getInstance(Locale.US);
        DecimalFormatSymbols symbols = df.getDecimalFormatSymbols();
        symbols.setGroupingSeparator(' ');
        df.setDecimalFormatSymbols(symbols);
        return df;
    }
}

Related Tutorials