Java BigDecimal Format formatNoDecimalPoint(double amt)

Here you can find the source of formatNoDecimalPoint(double amt)

Description

format No Decimal Point

License

Apache License

Declaration

public static String formatNoDecimalPoint(double amt) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    public static String formatNoDecimalPoint(double amt) {
        StringBuffer ret = new StringBuffer();

        String tmp = "";
        try {//from w  w  w  .java  2s  . co  m
            tmp = new Long(new BigDecimal(amt).longValue()).toString();
        } catch (NumberFormatException e) {
            return "";
        }

        int index = tmp.indexOf(".");
        if (index == -1) {
            ret.append(tmp);
        } else {
            tmp = tmp.substring(0, index);
            ret.append(tmp);
        }
        return ret.toString();
    }
}

Related

  1. formatFloat0(String value, int n)
  2. formatForPercentage(BigDecimal value)
  3. formatManey(BigDecimal date)
  4. formatMoney(BigDecimal money, int scale, double divisor)
  5. formatMoney(long value)
  6. formatNumber(double number)
  7. formatNumber(String format, BigDecimal number)
  8. formatNumberByMaxFrac(BigDecimal number, int val)
  9. formatNumberByMaxFracUseGrp(BigDecimal number, int val)