Advertisement
thorax232

Java - Decimal Formatting

Nov 11th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | None | 0 0
  1. import java.text.*;
  2.  
  3. public class DecimalPlaces {
  4.     public static void main(String[] args) {
  5.  
  6.         double d = 1.234567;
  7.         DecimalFormat df = new DecimalFormat("#.##");
  8.         df.setMaximumFractionDigits(2);
  9.         df.setMinimumFractionDigits(2);
  10.         System.out.print(df.format(d));
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement