Skip to content

Instantly share code, notes, and snippets.

@ssledz
Last active May 25, 2017 12:23
Show Gist options
  • Save ssledz/b0880907bdb9a907c69ba951f949a664 to your computer and use it in GitHub Desktop.
Save ssledz/b0880907bdb9a907c69ba951f949a664 to your computer and use it in GitHub Desktop.

Outputting floor numbers with two decimal digits with dot as a decimal separator

DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
symbols.setDecimalSeparator('.');
DecimalFormat df = new DecimalFormat("#.##", symbols);
df.setRoundingMode(RoundingMode.FLOOR);
df.setGroupingUsed(false);
df.format(1.2345); // 1.23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment