Java Utililty Methods BigDecimal Format

List of utility methods to do BigDecimal Format

Description

The list of methods to do BigDecimal Format are organized into topic(s).

Method

intfmtBdToInt(BigDecimal bd)
fmt Bd To Int
if (bd == null)
    return 0;
return bd.intValue();
Stringformat(BigDecimal amount, String format)
format
if (amount == null) {
    amount = BigDecimal.ZERO;
DecimalFormat decimalFormat = new DecimalFormat();
Locale lcl = Locale.FRENCH;
decimalFormat = (DecimalFormat) DecimalFormat.getInstance(lcl);
decimalFormat.applyPattern(format);
String value = decimalFormat.format(amount);
...
Stringformat(BigDecimal decData, int precision, int scale)
Format.
decData = decData.setScale(scale, BigDecimal.ROUND_HALF_EVEN);
String strData = decData.toString();
int finalLen = precision + 1;
String finalStr;
if (finalLen <= strData.length()) {
    finalStr = strData.substring(0, finalLen);
} else {
    finalStr = "";
...
Stringformat(BigDecimal decimal)
format
DecimalFormat df = new DecimalFormat("#,###.##");
return df.format(decimal);
BigDecimalformat(BigDecimal n, int prec)
Returns the BigDecimal value n with exactly 'prec' decimal places.
return n.setScale(prec, BigDecimal.ROUND_HALF_UP);
BigDecimalformat(BigDecimal n, int prec)
format
return n.setScale(prec, DEFAULT_ROUNDING_MODE);
Stringformat(BigDecimal no, String formatter)
format
DecimalFormat df = new DecimalFormat(formatter);
return df.format(no);
Stringformat(BigDecimal num)
format
java.text.DecimalFormat df = new java.text.DecimalFormat("0.00");
return df.format(num);
Stringformat(BigDecimal num)
format
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(100);
nf.setMinimumFractionDigits(0);
nf.setGroupingUsed(false);
return nf.format(num).replace(",", "."); 
Stringformat(BigDecimal num)
format
String result = "";
try {
    result = format(num.doubleValue());
} catch (Exception e) {
return result;