Example usage for java.text DecimalFormat DecimalFormat

List of usage examples for java.text DecimalFormat DecimalFormat

Introduction

In this page you can find the example usage for java.text DecimalFormat DecimalFormat.

Prototype

public DecimalFormat(String pattern) 

Source Link

Document

Creates a DecimalFormat using the given pattern and the symbols for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:Main.java

public static String AmountShow(double sum) {
    DecimalFormat df1 = new DecimalFormat("#,###,##0.00");
    return df1.format(sum);
}

From source file:Main.java

public static String addSeparateSign(int number) {
    DecimalFormat df = new DecimalFormat("#,###");
    return df.format(number);
}

From source file:Main.java

public static String getAmountFormat(double num) {
    DecimalFormat dft = new DecimalFormat("0.00");
    return dft.format(num);
}

From source file:Main.java

static public String FormatDoubleToNoDecimal(double inputvalue) {
    return new DecimalFormat("#").format(inputvalue);
}

From source file:Main.java

public static String convertToFatsString(double amount) {
    return "Fats: " + new DecimalFormat("####.##").format(amount) + "g";
}

From source file:Main.java

public static float changToTwoDecimal(float in) {
    DecimalFormat df = new DecimalFormat("0.00");
    String out = df.format(in);/*from   ww w .  jav a2  s. c  om*/
    return Float.parseFloat(out);
}

From source file:Main.java

public static String convertToCarbsString(double amount) {
    return "Carbs: " + new DecimalFormat("####.##").format(amount) + "g";
}

From source file:Main.java

public static String formatDouble(double d) {
    DecimalFormat formatter = new DecimalFormat("#,###.##");
    d = Math.round(d);/*from  w  w w  .  j a  v a  2  s  .  co  m*/
    return formatter.format(d);
}

From source file:Main.java

public static String convertToEatenString(double amount) {
    return "Eaten: " + new DecimalFormat("####.##").format(amount) + "g";
}

From source file:Main.java

public static String formatMoney(Double money) {
    DecimalFormat format = new DecimalFormat("###,##0.00");
    return format.format(money);
}