List of utility methods to do BigDecimal Format
String | format(BigDecimal number, String format) Method that formats the given BigDecimal into a String with the specified format if (number == null) return null; DecimalFormat snf = new DecimalFormat(format); return snf.format(number.doubleValue()); |
String | format(final BigDecimal bd) return a Number formatted or empty string if null. return bd != null ? NUMBER_FORMAT.format(bd) : ""; |
String | format(Object value, Integer precision) format Double number = Double.valueOf(0.0D); if (isDigit(value)) { number = new Double(value.toString()); precision = Integer.valueOf((precision == null) || (precision.intValue() < 0) ? 2 : precision.intValue()); BigDecimal bigDecimal = new BigDecimal(number.doubleValue()); return bigDecimal.setScale(precision.intValue(), 4).toString(); |
String | format(String pattern, final double secondInDouble) Format the duration. if ((Double.isNaN(secondInDouble)) || (secondInDouble == 0)) { return "0 second"; boolean isDayCalculated = false; boolean isHourCalculated = false; boolean isMinuteCalculated = false; boolean isSecondCalculated = false; pattern = pattern.toLowerCase(); ... |
String | format2Scale(BigDecimal obj) format Scale if (obj != null) { return obj.setScale(2, ROUNDING_MODE).toPlainString(); } else { return ""; |
String | format2String(BigDecimal bd) format String if (bd != null) { bd = bd.setScale(2, RoundingMode.HALF_UP); return bd.toString(); } else { return null; |
String | format_BigDecimal(BigDecimal decimal, Integer scale) forma Big Decimal if (decimal == null) { return null; if (scale == null) { return decimal.toPlainString(); return decimal.setScale(scale, RoundingMode.HALF_UP).toPlainString(); |
String | formatAmount(BigDecimal amount) format Amount return new DecimalFormat("#0.00").format(amount); |
String | formatAmount(BigDecimal amount) format Amount NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(0);
nf.setGroupingUsed(false);
return nf.format(amount);
|
String | formatAmount(final BigDecimal number) format Amount NumberFormat formatter = new DecimalFormat(".00"); return formatter.format(number); |