Here you can find the source of formatNumber(double i)
public static CharSequence formatNumber(double i)
//package com.java2s; import java.text.NumberFormat; public class Main { public static CharSequence formatNumber(long i) { float value = i; String suffix;// w w w . j ava 2 s . c om if (value >= 1000000000) { value = value / 1000000000f; suffix = "b"; } else if (value >= 1000000) { value = value / 1000000f; suffix = "m"; } else if (value > 1000) { value = i / 1000f; suffix = "k"; } else { return String.valueOf(i); } return String.format("%.1f%s", value, suffix); } public static CharSequence formatNumber(double i) { return NumberFormat.getInstance().format(i); } }