Here you can find the source of humanNumber(long num)
public static String humanNumber(long num)
//package com.java2s; //License from project: Open Source License public class Main { public static String humanNumber(long num) { StringBuilder msg = new StringBuilder(); if (num >= 0) { int mag = 0; while (num >= 1000) { num = num / 10;/*from w w w . jav a 2s . c o m*/ mag++; } char[] oMag = { 'K', 'M', 'G' }; if (mag > 0) msg.append(oMag[(mag - 1) / 3]); msg.insert(0, num); // and now the dot if (mag % 3 != 0) msg.insert(mag % 3, "."); } return msg.toString(); } }