Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to abbreviate numbers

807605Aug 3 2007 — edited Aug 3 2007
Need some ideas please.

I am formatting numbers for reports and sometimes I have really long numbers, but our customers don't like Scientific Notation. I also want to take into account local localization for number formating.

Am I reduced to using a code block such as:
if (number > 1,000,000,000)
{
    number = number / 1,000,000,000;
    string = numberformat.parse(number) + "B";
}
else if (number > 1,000,000)
{
    number = number / 1,000,000;
    string = numberformat.parse(number) + "M";
}
...
you get the idea I hope.

Is there nothing else I can do?

Thanks

-Dennis
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2007
Added on Aug 3 2007
23 comments
449 views