Android Int Format getDecimalFormat(int i, String numStr)

Here you can find the source of getDecimalFormat(int i, String numStr)

Description

get Decimal Format

Declaration

public static String getDecimalFormat(int i, String numStr) 

Method Source Code

//package com.java2s;

import java.math.BigDecimal;

public class Main {

    public static String getDecimalFormat(int i, String numStr) {
        try {// w ww . j  a  v a2 s .c o  m
            if (numStr != null && !"".equals(numStr)) {
                BigDecimal bd = new BigDecimal(numStr);
                bd = bd.setScale(i, BigDecimal.ROUND_HALF_UP);

                return bd.toString();
            } else {
                return "";
            }
        } catch (Exception e) {
            return "";
        }
    }
}

Related

  1. addCommas(int value)
  2. formatSpeed(int value)
  3. formatSpeed(int speed, String format)
  4. formatGameSize(int size)
  5. formatSpeed(int value)
  6. formatId(String id)
  7. formatInt(int number)