Skip to content

Instantly share code, notes, and snippets.

@kdabir
Created February 23, 2012 05:45
Show Gist options
  • Save kdabir/1890733 to your computer and use it in GitHub Desktop.
Save kdabir/1890733 to your computer and use it in GitHub Desktop.
Using DecimalFormat in java/groovy
import java.text.DecimalFormat;
...
DecimalFormat df = new DecimalFormat("###,##0.00");
df.format(number);
// in the format string,
// # -> shows Digit if present else blank
// 0 -> shows Digit if present else 0
// details at : http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment