Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.math.BigDecimal;

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    public static String toReal(Double value) {
        NumberFormat numberFormat = NumberFormat.getCurrencyInstance(new Locale("pt", "BR"));
        return numberFormat.format(value).replace("R$", "R$ ");
    }

    public static String toReal(BigDecimal value) {
        return toReal(value.doubleValue());
    }
}