List of utility methods to do Decimal Format
String | decimalFormat(double number) decimal Format return decimalFormat.format(number);
|
String | decimalFormat(Double numeric) Format Decimal number Locale.setDefault(new Locale("pt", "BR")); DecimalFormat decimal = new DecimalFormat(); decimal.applyPattern("#,##0.00"); return decimal.format(numeric / NUMBER_100).replaceAll(",", "."); |
String | decimalFormat(double value, int decimalCnt)String resultValue = ""; String pattern = ""; if (decimalCnt > 0) { for (int i = 0; i < decimalCnt; i++) { pattern += "#"; pattern = "." + pattern; DecimalFormat df = new DecimalFormat(pattern); ... |
String | decimalFormat(Object obj) decimal Format if (null == obj) return ""; DecimalFormat df = new DecimalFormat("0.00"); return df.format(obj); |
DecimalFormat | decimalFormat(String pattern) Creates a format. return new DecimalFormat(pattern, DecimalFormatSymbols.getInstance(Locale.ROOT)); |
String | decimalFormat(String pattern, double value) decimal Format return new DecimalFormat(pattern).format(value); |
String | decimalFormatLabel(final long value, final long divider, final String unit) Formats a decimal value using a specified divider final double result = divider > 1 ? (double) value / (double) divider : (double) value; return new DecimalFormat("#,##0.#").format(result) + " " + unit; |
String | decimalPointTwo(Float input) decimal Point Two if (input == null || input == 0) { return "0.0"; DecimalFormat df = new DecimalFormat("#.##"); df.setRoundingMode(RoundingMode.FLOOR); return df.format(input); |
String | decimalString(double d, boolean forceDigits) decimal String return forceDigits ? dfForce.format(d) : df.format(d);
|
String | encodeDouble(double d) encode Double String decimalString = FULL_DECIMAL_FORMAT.format(d); int splitPoint = decimalString.indexOf('E'); String significand = decimalString.substring(0, splitPoint); String exponent = decimalString.substring(splitPoint + 1); boolean negativeExponent = exponent.startsWith("-"); String result; if (significand.startsWith("-")) { BigDecimal significandValue = new BigDecimal(significand); ... |