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
 

Related Posts:

  • 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: … Read More
  • Eclipse - Convert java project to web project Right Click Java Project, in Project Facets section: select Dynamic Web Modules & Java … Read More
  • Java - Access restriction rt.jarGo to the Build Path settings in the project properties. Remove the JRE System Library Add it back; Select "Add Library" and select the JRE System Library Source: http://stackoverflow.com/questions/860187/access-restriction… Read More

0 comments:

Post a Comment