List of usage examples for java.text DecimalFormat format
public final String format(double number)
From source file:Main.java
public static String CalculatePraise(int num) { if (num > 1000) { double d = (double) num / 1000; DecimalFormat decimalFormat = new DecimalFormat("0.0"); return decimalFormat.format(d) + "K"; }/*www . j av a 2 s . c om*/ return Integer.toString(num); }
From source file:Main.java
/** * Process inch value./*from w w w .j av a 2s . co m*/ */ public static String toInch(double size) { //Rounding-off method. Remain 2 decimal number. DecimalFormat decimalFormat = new DecimalFormat("#0.00\""); return decimalFormat.format(size); }
From source file:Main.java
public static String decimalFormat(String s, String format) { DecimalFormat decimalFormat = new DecimalFormat(format); return decimalFormat.format(s); }
From source file:Main.java
public static String handleDouble(double price) { DecimalFormat decimalFormat = new DecimalFormat("##.##"); return decimalFormat.format(price); }
From source file:Main.java
public static String BTC2Fiat(String btc) { double val = 0.0; try {// w ww . jav a 2 s. c o m val = Double.parseDouble(btc); } catch (NumberFormatException nfe) { val = 0.0; } DecimalFormat df = new DecimalFormat("######0.00"); return df.format(BTC2Fiat(val)); }
From source file:Main.java
public static String Fiat2BTC(String fiat) { double val = 0.0; try {//from w ww . ja v a 2s . c o m val = Double.parseDouble(fiat); } catch (NumberFormatException nfe) { val = 0.0; } DecimalFormat df = new DecimalFormat("####0.0000"); return df.format(Fiat2BTC(val)); }
From source file:Main.java
public static double getProgress(int progress) { double temp = progress * 1.0; double pro = temp / 1024 / 1024; DecimalFormat df = new DecimalFormat("######0.00"); return Double.parseDouble(df.format(pro)); }
From source file:Main.java
public static String formatPrice(String price) { String tempPrice = "0"; if (null != price && !"".equals(price)) { double d = Double.parseDouble(price); if (d != 0) { DecimalFormat df = new DecimalFormat("##0.00"); tempPrice = df.format(Double.parseDouble(price)); }// w w w . ja v a2 s .c om } return tempPrice; }
From source file:Main.java
public static String getFileSizeDescription(Context context, long bytes) { String value = ""; if (bytes < 1000) { value = (int) bytes + "B"; } else if (bytes < 1000000) { value = Math.round(bytes / 1000.0) + "K"; } else if (bytes < 1000000000) { DecimalFormat df = new DecimalFormat("#0.0"); value = df.format(bytes / 1000000.0) + "M"; } else {//from w w w. ja va 2s .co m DecimalFormat df = new DecimalFormat("#0.00"); value = df.format(bytes / 1000000000.0) + "G"; } return value; }
From source file:Main.java
public static String getTwoPointString(double d) { if (d == 0)/*from ww w . j a va 2s. c o m*/ return "0.00"; try { DecimalFormat df = new DecimalFormat("######0.00"); String text = df.format(d); return text; } catch (Exception e) { return "0.00"; } }