Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String addCommasToStringNumber(String number) { double num = 0; DecimalFormat formatter; try { num = Double.parseDouble(number); formatter = new DecimalFormat("#,###"); } catch (Exception e) { return number; } return formatter.format(num); } }