Java - Write code to parse string to double with comma Separator

Requirements

Write code to parse string to double with comma Separator

Demo

//package com.book2s;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

public class Main {
    public static void main(String[] argv) {
        String number = "123,123";
        System.out.println(commaSeparator(number));
    }// w w  w . java2 s . co m

    public static String commaSeparator(String number) {

        Double d = Double.parseDouble(number);

        DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
        symbols.setGroupingSeparator('?');

        DecimalFormat formatter = new DecimalFormat("###,###", symbols);

        String str = formatter.format(d);

        return str;
    }
}