List of utility methods to do BigDecimal Format
BigDecimal | formatBigDecimal(String value) Checks if the value can safely be converted to a BigDecimal. if (value == null) { return null; try { return new BigDecimal(value); } catch (NumberFormatException e) { return null; |
String | formatBigDecimalWithPrecise(BigDecimal number) format bigdecimal to string String result = ""; NumberFormat nbf = new DecimalFormat("#,##0.00"); if (number != null) { result = nbf.format(number.doubleValue()); return result; |
String | formatCents(int cents) format Cents return centsToUnit(cents).toPlainString();
|
String | formatCUBRIDNumber(BigDecimal value) Format number to fit for CUBRID numeric type. return new DecimalFormat(DEFAULT_NUMERIC_FORMAT).format(value); |
String | formatDecimal(BigDecimal b) format Decimal if (b == null) { return null; Locale loc = new Locale("nl", "NL", "EURO"); NumberFormat n = NumberFormat.getCurrencyInstance(loc); double doublePayment = b.doubleValue(); String s = n.format(doublePayment); return s; ... |
String | formatDecimal(BigDecimal num) format Decimal return NumberFormat.getInstance(Locale.US).format(num);
|
String | formatDecimal(BigDecimal number, int maxFractionDigits, int minFractionDigits) Formats a number so that the number of digits in the fraction portion of it is bound by a maximum value and a minimum value. DecimalFormat df = new DecimalFormat(); df.setGroupingUsed(false); df.setMaximumFractionDigits(maxFractionDigits); df.setMinimumFractionDigits(minFractionDigits); return df.format(number); |
String | formatDecimalCost(BigDecimal value) format Decimal Cost Currency currency = Currency.getInstance(Locale.getDefault());
NumberFormat fmt = DecimalFormat.getInstance();
fmt.setMinimumFractionDigits(2);
fmt.setMaximumFractionDigits(2);
return currency.getSymbol() + fmt.format(value);
|
double | formatDigit(double value, int scale) format Digit BigDecimal bd = new BigDecimal(value); bd = bd.setScale(scale, BigDecimal.ROUND_HALF_UP); double d = bd.doubleValue(); bd = null; return d; |
String | formatDouble(double d) format Double String[] plain = printDouble(d).split("\\."); String formatted = ""; while (plain[0].length() >= 4) { formatted = "'" + plain[0].substring(plain[0].length() - 3) + formatted; plain[0] = plain[0].substring(0, plain[0].length() - 3); formatted = plain[0] + formatted; if ((plain.length > 1) && (tryParse(plain[1], 0) != 0)) { ... |