Java Decimal Format decimalFormat(double no)

Here you can find the source of decimalFormat(double no)

Description

decimal Format

License

Open Source License

Declaration

public static String decimalFormat(double no) 

Method Source Code


//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    public static String decimalFormat(double no) {
        DecimalFormat df = new DecimalFormat("######.##");
        String val = df.format(no);
        int index = val.indexOf(".");
        if (index == -1)
            val = val + ".00";
        else {//from  www  .  j  a  v a2  s .c o m
            if (val.substring(index + 1, val.length()).length() - 1 == 0)
                val = val + "0";
        }
        return val;
    }
}

Related

  1. decimal2percent(double decimal, int pos)
  2. decimal2string(BigDecimal arg, Locale loc)
  3. decimalConversation(double amount)
  4. decimalFormat()
  5. decimalFormat(double d)
  6. decimalFormat(double number)
  7. decimalFormat(Double numeric)
  8. decimalFormat(double value, int decimalCnt)
  9. decimalFormat(Object obj)