Here you can find the source of beautifyMoney(long money)
public static String beautifyMoney(long money)
//package com.java2s; public class Main { public static String beautifyMoney(long money) { String res = ""; String tmp = String.valueOf(money); Boolean isNegative = false; if (tmp.indexOf("-") >= 0) { isNegative = true;/*w w w . ja v a2 s . c o m*/ tmp = tmp.replace("-", ""); } int length = tmp.length(); int count = 0; for (int i = length - 1; i >= 0; i--) { if (i < length - 1 && count % 3 == 0) { res = "." + res; } res = tmp.charAt(i) + res; count++; } if (isNegative) { res = '-' + res; } return res; } }