Example usage for java.text DecimalFormat format

List of usage examples for java.text DecimalFormat format

Introduction

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

Prototype

public final String format(double number) 

Source Link

Document

Specialization of format.

Usage

From source file:Main.java

/**
 * Returns formatted distance.//from  w w  w.ja va2 s . c o m
 * @param distance
 * @return formatted distance
 */
public static String formatDistance(float distance) {

    DecimalFormat format = new DecimalFormat("0.00");
    return format.format(distance);
}

From source file:Main.java

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

From source file:Main.java

public static String formatToYuanYXS(String money) {
    DecimalFormat df = new DecimalFormat("#0.0");
    return df.format(formatToYuan(money));
}

From source file:Main.java

public static String decimalFormat(double s, String format) {
    DecimalFormat decimalFormat = new DecimalFormat(format);
    return decimalFormat.format(s);
}

From source file:Main.java

public static String formatDistance(double distance) {
    String dis = "0";
    DecimalFormat df = new DecimalFormat("0.0");
    String result = df.format(distance);
    return result;
}

From source file:Main.java

public static String getString(double value) {
    DecimalFormat df = new DecimalFormat("#####0");
    String target = df.format(value);
    return target;
}

From source file:Main.java

public static String getMoneyPattern(double money) {
    DecimalFormat formatter = new DecimalFormat("#,###.##");
    return formatter.format(money).replace(',', '.').concat(" TL ");
    //String s = String.format(TimeUtil.localeTr,"%,f", money).replace(',','.').concat(" TL");
}

From source file:Main.java

public static String formatedIntStringFromInput(String inputStr) {
    Long n = longFromString(inputStr);
    DecimalFormat df = new DecimalFormat("#,###");
    return df.format(n);
}

From source file:Main.java

public static String getMoneyPatternWithoutCurrency(double money) {
    DecimalFormat formatter = new DecimalFormat("#,###.##");
    return formatter.format(money).replace(',', '.');
    //String s = String.format(TimeUtil.localeTr,"%,f", money).replace(',','.').concat(" TL");
}

From source file:Main.java

public static String getMoneyDisplay(BigDecimal amount) {
    if (amount == null) {
        return "0.00";
    } else {//ww  w.  j  ava  2 s. c  o  m
        DecimalFormat df = new DecimalFormat("##.00");
        return df.format(amount.setScale(2, BigDecimal.ROUND_DOWN));
    }
}