Java Data Type How to - Convert string numbers into comma seperated integers


We would like to know how to convert string numbers into comma seperated integers.


import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Locale;
/* w  w w  .  j  ava 2 s .  c o  m*/
public class Main {
  public static void main(String[] args) {
    BigDecimal payment = new BigDecimal("12345.67");
    NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
    double doublePayment = payment.doubleValue();
    String s = n.format(doublePayment);

The code above generates the following result.