• Post Reply Bookmark Topic Watch Topic
  • New Topic

Comma format for decimal numbers  RSS feed

 
Kiran Baratam
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I need to display resultant values in commaseperated format.
I am using the below code
NumberFormat textformat = NumberFormat.getNumberInstance();
return textformat.format(input parameter);
This is working fine as long as the input parameter does't contain any decimal places.
if it contains its ignoring them and formating.
EX : 12334242 ---- working fine.
12334242.65 -- not working. Ignoring .65.
Please advise me some solution.
Regards
kiran
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Working with decimal numbers, eh? Perhaps you should look into java.text.DecimalFormat
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!