Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Number

Status
Not open for further replies.

varavoorvishnu

Programmer
Sep 9, 2002
45
Hi All,
How to format a given number say 1231231323.4234 which is a double to comma seperated with the 2 digits after the decimal point.
I dont want to use the conventional convertion into string and use substring to display 2 digits after the decimal,instead i want to use the existing methods.
I used DecimalFormat("1231231323.4234", "#,##0.0#" ) ;
which gave error.
Have anyone used this method.Any new existing methods also appreciated.

Vishnu
 
I tried this and its working for me.

double d = 123123123.1234;
DecimalFormat df = new DecimalFormat("#,##0.00");
System.out.println(df.format(d));

Try again, hope it will work now.

Sachin
 
Hi Sachin,
Thnz for the splendid effort.
I have solved the problem the same day.

Vishnu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top