List of utility methods to do Double Format
String | formatToTwoDecimalPlaces(String decimal) format To Two Decimal Places try { return format.format(format.parse(decimal)); } catch (ParseException e) { return decimal; |
String | formatPriceWithTwoDecimals(Locale locale, double doubleToFormat) Format String like a price with two decimals WARNING: Only use this method to present data to the screen DecimalFormat formatter = new DecimalFormat(); setupFormatter(formatter, locale, 2); return formatter.format(doubleToFormat); |
double | decimalFormat(int i, Double num) decimal Format String temp = getDecimalFormat(i, num.toString()); double numFormat = Double.valueOf(temp); return numFormat; |
String | priceFormat(double price, String pattern) price Format 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); ... |
String | formatCurrency(int cents) format Currency double amount = ((double) cents) / 100; return String.format("$%.2f", amount); |
String | formatBalance(Double balance, String curr) format Balance return formatBalance(new BigDecimal(balance), curr); |
String | formatDoubleToTwoDecimalString(double number) format Double To Two Decimal String double theNumber = calculateRechargeAmountInRandsFor(number); return twoDecimalDoubleFormatter(theNumber); |
String | formatDouble(final double num) format Double final DecimalFormat df = new DecimalFormat("#,###.00"); boolean hasFloating = false; if (num - (int) num != 0) { hasFloating = true; if (hasFloating) { return df.format(num); } else { ... |