Java examples for java.math:BigDecimal
get Decimal Amount via BigDecimal
//package com.java2s; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; public class Main { private static final int MC_PRECISION = 4; private static final int MC_SCALE = 2; public static BigDecimal getDecimalAmount(String parsedAmount) { return (new BigDecimal(parsedAmount, new MathContext(MC_PRECISION))) .setScale(MC_SCALE, RoundingMode.HALF_EVEN); }//ww w .j a va2 s.c om }