List of utility methods to do BigDecimal Parse
BigDecimal | parseBigDecimal(String number, BigDecimal defValue) parse Big Decimal try { if (number != null && !number.isEmpty()) return new BigDecimal(number); } catch (Exception e) { e.printStackTrace(); return defValue; |
BigDecimal | parseBigDecimalForEntity(String bigDecimalString) parse Big Decimal For Entity if (bigDecimalString == null) { return null; bigDecimalString = bigDecimalString.trim(); bigDecimalString = bigDecimalString.replaceAll(",", ""); if (bigDecimalString.length() < 1) { return null; return new BigDecimal(bigDecimalString); |
BigDecimal | parseTo_BigDecimal(String s) parse T Big Decimal if (isBlank(s)) { return null; return new BigDecimal(s); |
BigDecimal | parseTo_BigDecimal(String s) parse T Big Decimal if (s == null) { return null; try { return new BigDecimal(s); } catch (NumberFormatException nfe) { if (nfe.getMessage() == null) { throw new NumberFormatException("Incorrect input \"" + s + "\" for BigDecimal."); ... |
BigDecimal | parseToBigDecimal(Object value) parse To Big Decimal if (value == null) { return null; if (value instanceof Byte) { return new BigDecimal((Byte) value); } else if (value instanceof Double) { return new BigDecimal((Double) value); } else if (value instanceof Float) { ... |
BigDecimal | string2BigDecimal(String valor) string Big Decimal BigDecimal valorBig = BigDecimal.ZERO; Locale brasil = new Locale("pt", "BR"); DecimalFormat df = new DecimalFormat("#,##0.00", new DecimalFormatSymbols(brasil)); df.setParseBigDecimal(true); valorBig = (BigDecimal) df.parse(valor); return valorBig; |
BigDecimal | stringToBigDecimal(String numeroStr) string To Big Decimal DecimalFormatSymbols symbols = new DecimalFormatSymbols(new Locale("pt", "BR")); symbols.setDecimalSeparator(','); symbols.setCurrencySymbol(""); DecimalFormat decimalFormat = new DecimalFormat("#,##0.0#", symbols); decimalFormat.setDecimalFormatSymbols(symbols); decimalFormat.setGroupingUsed(false); decimalFormat.setParseBigDecimal(true); decimalFormat.setMinimumFractionDigits(2); ... |
Float | strToFloat(String text, int decimals) Parses a string to produce a Float with a number of fraction digits. try { return new Float(getFormat(decimals).parse(text).floatValue()); } catch (Exception except) { except.printStackTrace(); return null; |
String | toDecimalString(String str, int decimal) to Decimal String if (null == str) { return ""; return toDecimalString(Double.valueOf(str.trim()), decimal); |