List of utility methods to do BigDecimal Format
BigDecimal | formatNumberStr(String numberStr, Integer scale) format Number Str BigDecimal bigVal = null; try { bigVal = new BigDecimal(numberStr); if (null == scale) return bigVal; return bigVal.setScale(scale, BigDecimal.ROUND_HALF_UP); } catch (Exception e) { return null; ... |
String | formatNumer(BigDecimal value, int decimalPlaces, Locale locale, boolean roundCommercial) format Numer DecimalFormat df = getDecimalFormat(decimalPlaces, locale); if (roundCommercial) { return df.format(roundCommercial(value, decimalPlaces)); return df.format(value); |
String | formatoDecimal(String tipo, BigDecimal valor) formato Decimal String mascara = "0."; if (tipo.equals("Q")) { for (int i = 0; i < DECIMAL_QUANTIDADE; i++) { mascara += "0"; } else if (tipo.equals("V")) { for (int i = 0; i < DECIMAL_VALOR; i++) { mascara += "0"; ... |
String | formatPercent(BigDecimal percent) format Percent return df.format(Double.parseDouble(percent.toString())) + " %"; |
String | formatPercentage(BigDecimal percentage) Formats a BigDecimal representing a percentage into a string if (percentage == null) return ""; return percentageDecimalFormat.format(percentage); |
Double | formatPercentDecimalDouble(Object input) format Percent Decimal Double if (checkInput(input)) { BigDecimal bd1 = new BigDecimal(input.toString()); BigDecimal bd2 = new BigDecimal("100"); return bd1.multiply(bd2).doubleValue(); return null; |
String | formatQuantity(BigDecimal quantity) Formats an BigDecimal representing a quantity into a string if (quantity == null) return ""; else return quantityDecimalFormat.format(quantity); |
String | formatQuantity(BigDecimal quantity) format Quantity return trim(quantity.toPlainString().replace('.', ',')); |
String | formatRate(BigDecimal rate) format Rate return rate.multiply(new BigDecimal(100)).toPlainString() + "%"; |
String | formatRateForDisplay(BigDecimal rate) format Rate For Display String outputString = "0.0000"; if (null != rate) { if (BigDecimal.ZERO.setScale(10, RoundingMode.HALF_UP) .compareTo(rate.setScale(10, RoundingMode.HALF_UP)) == 0) { } else { BigDecimal tempRate = rate.setScale(4, RoundingMode.HALF_UP); if (BigDecimal.ZERO.setScale(4, RoundingMode.HALF_UP).compareTo(tempRate) == 0) { outputString = rate.toPlainString(); ... |