Tuesday, April 10, 2012

Double Format

public class Main {

    public static void main(String[] args) {
  
        java.text.DecimalFormat df = new java.text.DecimalFormat("###.##");
        double val = 63.5666;
     
            try {
                val = df.parse(df.format(val)).doubleValue();
                System.out.println(val);
            } catch (ParseException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
       
    }
}

No comments:

Post a Comment