Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    public static String formatMoneyAmountBills(double amount, Locale locale) {
        NumberFormat format = NumberFormat.getCurrencyInstance(locale);

        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;

        return (amountTxt);
    }
}