Here you can find the source of formatSmallerNumber(String prefix, String suffix, long amnt, boolean useDecimals)
private static String formatSmallerNumber(String prefix, String suffix, long amnt, boolean useDecimals)
//package com.java2s; //License from project: Open Source License public class Main { private static String formatSmallerNumber(String prefix, String suffix, long amnt, boolean useDecimals) { switch (Long.toString(amnt).length()) { case 4:/*from ww w. j a va 2 s .c o m*/ prefix += Long.toString(amnt).substring(0, 1) + (useDecimals ? "." + Long.toString(amnt).substring(1, 3) : "") + "K" + suffix; return prefix; case 5: prefix += Long.toString(amnt).substring(0, 2) + (useDecimals ? "." + Long.toString(amnt).substring(2, 4) : "") + "K" + suffix; return prefix; case 6: prefix += Long.toString(amnt).substring(0, 3) + (useDecimals ? "." + Long.toString(amnt).substring(3, 5) : "") + "K" + suffix; return prefix; } return ""; } }