Java BigDecimal Round round(BigDecimal value, String currency)

Here you can find the source of round(BigDecimal value, String currency)

Description

round

License

Open Source License

Declaration

public static BigDecimal round(BigDecimal value, String currency) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Main {
    public static BigDecimal round(BigDecimal value, String currency) {

        if (currency == null) {
            return value.setScale(2, BigDecimal.ROUND_HALF_UP);
        } else {// w  w  w. ja  va2  s .  c  o m
            //TODO get rounding configuration to round value
            return value.setScale(2, BigDecimal.ROUND_HALF_UP);
        }

    }

    public static Map round(Map values, String currency) {
        Map result = new HashMap();

        Iterator itr = values.keySet().iterator();
        while (itr.hasNext()) {
            Object key = itr.next();

            Object value = values.get(key);
            if (value instanceof BigDecimal) {
                BigDecimal roundValue = round((BigDecimal) value, currency);
                result.put(key, roundValue);
            }
        }
        return result;
    }
}

Related

  1. round(BigDecimal value)
  2. round(BigDecimal value)
  3. round(BigDecimal value, BigDecimal increment, RoundingMode roundingMode)
  4. round(BigDecimal value, int accuracy)
  5. round(BigDecimal value, int places)
  6. round(BigDecimal what, int howmuch)
  7. round(final BigDecimal input, final int precision)
  8. round(final BigDecimal number, final int minFractionDigits, final int maxFractionDigits, final RoundingMode roundingMode)
  9. round_BigDecimal(double d, int decLen)