Android Float Format priceFormat(float price, String pattern)

Here you can find the source of priceFormat(float price, String pattern)

Description

price Format

Declaration

public static String priceFormat(float price, String pattern) 

Method Source Code

//package com.java2s;
import java.text.DecimalFormat;

public class Main {

    public static String priceFormat(double price, String pattern) {
        String str = "0";
        double anotherNan = Double.NaN;
        if (Double.compare(price, anotherNan) != 0) {
            DecimalFormat df1 = new DecimalFormat(pattern);
            str = df1.format(price);//  w w  w . j  a v a  2s . c  o m
        } else {
            DecimalFormat df1 = new DecimalFormat(pattern);
            str = df1.format(str);
        }
        return str;
    }

    public static String priceFormat(float price, String pattern) {
        String str = "0";
        double anotherNan = Double.NaN;
        if (Double.compare(price, anotherNan) != 0) {
            DecimalFormat df1 = new DecimalFormat(pattern);
            str = df1.format(price);
        } else {
            DecimalFormat df1 = new DecimalFormat(pattern);
            str = df1.format(str);
        }
        return str;
    }
}

Related

  1. formatSpeed(float data)
  2. formatSpeed(float data, String format)
  3. formatSpeedValue(float speed)
  4. formatSpeedWithUnit(float speed)
  5. formatSpeed(float bytesPerSecond)