List of usage examples for java.text DecimalFormat DecimalFormat
public DecimalFormat(String pattern)
From source file:Main.java
public static String changeFormat(String str, String formats) { DecimalFormat df = new DecimalFormat(formats); return df.format(str); }
From source file:Main.java
public static String priceWithoutDecimal(Double price) { DecimalFormat formatter = new DecimalFormat("###,###,###,###.###"); return formatter.format(price); }
From source file:Main.java
public static String setFileSize(long size) { DecimalFormat df = new DecimalFormat("###.##"); float f = ((float) size / (float) (1024 * 1024)); if (f < 1.0) { float f2 = ((float) size / (float) (1024)); return df.format(new Float(f2).doubleValue()) + "KB"; } else {/*from w w w . j a va 2 s .co m*/ return df.format(new Float(f).doubleValue()) + "M"; } }
From source file:Main.java
public static String FormetFileSize(long fileS) { DecimalFormat df = new DecimalFormat("#.00"); String fileSizeString = ""; if (fileS < 1024) { fileSizeString = df.format((double) fileS) + "B"; } else if (fileS < 1048576) { fileSizeString = df.format((double) fileS / 1024) + "K"; } else if (fileS < 1073741824) { fileSizeString = df.format((double) fileS / 1048576) + "M"; } else {/*w w w . j a v a2 s . c o m*/ fileSizeString = df.format((double) fileS / 1073741824) + "G"; } return fileSizeString; }
From source file:Main.java
public static String formetFileSize(long fileS) { DecimalFormat df = new DecimalFormat("#.00"); String fileSizeString = ""; if (fileS < 1024) { fileSizeString = fileS + " B"; } else if (fileS < 1048576) { fileSizeString = df.format((double) fileS / 1024) + " K"; } else if (fileS < 1073741824) { fileSizeString = df.format((double) fileS / 1048576) + " M"; } else {/* w w w . j a v a 2s. c o m*/ fileSizeString = df.format((double) fileS / 1073741824) + " G"; } return fileSizeString; }
From source file:Main.java
public static String getStringFromFloat(float price, String format) { DecimalFormat df = new DecimalFormat("#0.00"); return df.format(price); }
From source file:Main.java
public static String lbToST(float paramFloat) { float f = paramFloat * 14.0F; return new DecimalFormat("######.00").format(f); }
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 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 double convertKMToMiles(String kilometers) { DecimalFormat decimalFormat = new DecimalFormat("#"); int km = Integer.parseInt(kilometers); double miles = 0.621 * km; decimalFormat.format(miles);/*from w w w . ja v a 2 s . c o m*/ return Math.abs(miles); }