Here you can find the source of formatThousands(String inValue)
public static String formatThousands(String inValue)
//package com.java2s; /*//from w w w . j av a 2s . co m * Copyright (c) 2013, 2014 Chris Newland. * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki */ import java.text.DecimalFormat; public class Main { private static final DecimalFormat DF_THOUSANDS = new DecimalFormat("#,###"); public static String formatThousands(String inValue) { String value = inValue; // see if it can be formatted as a long with commas at thousands try { value = DF_THOUSANDS.format(Long.parseLong(value)); } catch (NumberFormatException nfe) { } return value; } }