Skip to content

Instantly share code, notes, and snippets.

@vanloc0301
Created February 15, 2019 11:49
Show Gist options
  • Save vanloc0301/8c7b1f329962288858123f2fcf0f31f1 to your computer and use it in GitHub Desktop.
Save vanloc0301/8c7b1f329962288858123f2fcf0f31f1 to your computer and use it in GitHub Desktop.
public long removerSeparadoresDeValor(final BigDecimal bigDecimal) {
final DecimalFormat decimalFormat = (DecimalFormat)NumberFormat.getCurrencyInstance(new Locale("pt", "BR"));
decimalFormat.setMaximumFractionDigits(2);
final DecimalFormatSymbols decimalFormatSymbols = decimalFormat.getDecimalFormatSymbols();
decimalFormatSymbols.setCurrencySymbol("");
decimalFormat.setDecimalFormatSymbols(decimalFormatSymbols);
return Long.valueOf(decimalFormat.format(bigDecimal).replace(".", "").replace(",", "").trim());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment