Created
          February 23, 2012 05:45 
        
      - 
      
- 
        Save kdabir/1890733 to your computer and use it in GitHub Desktop. 
    Using DecimalFormat in java/groovy
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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