Java tutorial
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; import java.util.Locale; public class Main { public static String formatMoneyAmountOne(double amount) { Locale locale = new Locale("ru", "RU"); NumberFormat format = NumberFormat.getCurrencyInstance(locale); format.setMinimumFractionDigits(0); format.setMaximumFractionDigits(1); String amountTxt = format.format(amount); String amountTxtValue = ""; for (int i = 0; i < amountTxt.length(); i++) { if (Character.isDigit(amountTxt.charAt(i)) || amountTxt.charAt(i) == '.' || amountTxt.charAt(i) == ',') amountTxtValue = amountTxtValue + amountTxt.charAt(i); } amountTxt = amountTxtValue; if (amountTxt.endsWith(",00")) return (amountTxt.replace(",00", "")); else if (amountTxt.endsWith("0") && amountTxt.contains(",")) { return (amountTxt.substring(0, amountTxt.length() - 1)); } else return (amountTxt); } }