Java Double Number Format convertDouble(double damage)

Here you can find the source of convertDouble(double damage)

Description

Convert endless decimal health to a 2 lengthed one.

License

Open Source License

Parameter

Parameter Description
damage the amount of damage to convert.

Return

The new damage amount with 2 lenghted decimal.

Declaration

public static String convertDouble(double damage) 

Method Source Code


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

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    /**//from   w w  w.j  av  a 2  s . co  m
     * Convert endless decimal health to a 2 lengthed one.
     * 
     * @param damage the amount of damage to convert.
     * @return The new damage amount with 2 lenghted decimal.
     */
    public static String convertDouble(double damage) {
        NumberFormat nf = new DecimalFormat("##.##");
        return nf.format(damage);
    }
}

Related

  1. doubleFormat(Double d)
  2. doubleFormat(double d)
  3. doubleFormat(double number)
  4. doubleFormat(double val, boolean hiRes)