Tuesday, May 14, 2013

Java - Number/Date Formating

Number Formating

 
String number = "1000500000.574";
double amount = Double.parseDouble(number);
DecimalFormat formatter = new DecimalFormat("#,###.00");
System.out.println(formatter.format(amount));
 
Result: 
1,000,500,000.57 

20 --> DecimalFormat("###.0"); result: 20.0
 

0 comments:

Post a Comment