/**
 * 
 */
package com.rjconsultores.ventaboletos.web.utilerias;

import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Locale;

/**
 * @author Bruno H. G. Gouvêa <bruno@rjconsultores.com.br>
 * 
 */
public final class CurrencyUtil {

	public static String getCurrencyStrFromStr(String value, Locale locale) {
		NumberFormat moedaFormat = NumberFormat.getCurrencyInstance(locale);
		return moedaFormat.format(Double.parseDouble(value));
	}

	public static String getCurrencyBigDecimalFromStr(BigDecimal value, Locale locale) {
		NumberFormat moedaFormat = NumberFormat.getCurrencyInstance(locale);
		return moedaFormat.format(value.doubleValue());
	}

	public static String getPercentStrFromStr(String value, Locale locale) {
		NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
		percentFormat.setMinimumFractionDigits(2);
		return percentFormat.format(Double.parseDouble(value));
	}

	public static String getPercentBigDecimalFromStr(BigDecimal value, Locale locale) {
		NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
		percentFormat.setMinimumFractionDigits(2);
		return percentFormat.format(value.doubleValue());

	}

}
