Here you can find the source of formatNumber(double value)
public static String formatNumber(double value)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatNumber(double value) { if (value < 1000D) return String.valueOf(value); else if (value < 1000000D) return String.valueOf(Math.round(value) / 1000D) + "K"; else if (value < 1000000000D) return String.valueOf(Math.round(value / 1000D) / 1000D) + "M"; else if (value < 1000000000000D) return String.valueOf(Math.round(value / 1000000D) / 1000D) + "B"; else//w w w . j a va2s . c o m return String.valueOf(Math.round(value / 1000000000D) / 1000D) + "T"; } }