/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package br.usp.nds.remote.conversao; import java.math.BigDecimal; import java.text.NumberFormat; import java.util.Locale; import org.apache.commons.beanutils.Converter; /** * * @author 316030740116 */ public class BigDecimalConverter implements Converter { public static final Locale LOCALE = new Locale("pt", "BR"); public BigDecimal convert(Class type, Object string) { try { return new BigDecimal(NumberFormat.getNumberInstance(LOCALE).parse( string.toString()).doubleValue()).setScale(2, BigDecimal.ROUND_HALF_EVEN); } catch (Exception e) { return null; } } }