Decimalformat to format decimal points


/ Published in: Java
Save to your folder(s)

Use this small snippet to change doubles from 123.1234567890 to whatever you wish


Copy this code and paste it in your HTML
  1. import java.text.*;
  2.  
  3. DecimalFormat fmt = new DecimalFormat("$0.00");
  4.  
  5. double test = 1337.09879475398758784;
  6. System.out.println("Fixed Double: " + fmt.format(test));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.