Here you can find the source of translateMoneyStr(String money)
public static String translateMoneyStr(String money)
//package com.java2s; /*/*from ww w .ja va 2 s .c o m*/ * Aipo is a groupware program developed by Aimluck,Inc. * Copyright (C) 2004-2011 Aimluck,Inc. * http://www.aipo.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static String translateMoneyStr(String money) { if (money == null || money.length() == 0) { return money; } StringBuffer sb = new StringBuffer(); int len = money.length(); int count = len / 3; int del = len % 3; sb.append(money.substring(0, del)); if (count > 0) { if (len > 3 && del != 0) { sb.append(","); } for (int i = 0; i < count; i++) { sb.append(money.substring(del + 3 * i, del + 3 * i + 3)); if (i != count - 1) { sb.append(","); } } } return sb.toString(); } }