Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2005

Tip: Looking for answers? Try searching our database.

commas in numbers

Thread view: 
normalkid - 29 Sep 2005 04:07 GMT
Hey, i need some help with creating a method that displays any long using
commas. example 123456 to 123,456. A easy and simple one would be
appreciated thank you.
jessu - 29 Sep 2005 05:18 GMT
NumberFormat.getInstance().format( yourNumber )

---------
FeedFeeds : A new way to read news and blogs!
http://www.feedfeeds.com
Thomas G. Marshall - 29 Sep 2005 19:00 GMT
jessu coughed up:
> NumberFormat.getInstance().format( yourNumber )

YES.  In fact, you should almost *always* use NumberFormat for both writing
and reading in numbers.

NumberFormat is locale sensitive.  If your program is run by some person in
the UK, it'll know to swap the "." and ",".  If in some of the weirder
countries, it knows to group some of the digits by four.

Try to use it's parse() as well!!!!  Many times you'll get a user enterring
in (say)

   12,440.00

For input.  You want this to work seamlessly!  Far more likely, in the UK
you might get:

   124400,00

You just don't want your program to gack on this.

> ---------
> FeedFeeds : A new way to read news and blogs!
> http://www.feedfeeds.com 
Oliver Wong - 29 Sep 2005 22:57 GMT
> Try to use it's parse() as well!!!!  Many times you'll get a user
> enterring in (say)
[quoted text clipped - 5 lines]
>
>    124400,00

   Everything is 10 times more expensive in the UK...

   - Oliver
Thomas G. Marshall - 30 Sep 2005 02:21 GMT
Oliver Wong coughed up:

>> Try to use it's parse() as well!!!!  Many times you'll get a user
>> enterring in (say)
[quoted text clipped - 9 lines]
>
>    - Oliver

LOL.  Made my night, thank you.
Roedy Green - 29 Sep 2005 06:57 GMT
>Hey, i need some help with creating a method that displays any long using
>commas. example 123456 to 123,456. A easy and simple one would be
>appreciated thank you.
see http://mindprod.com/applet/converter.html

You want to convert long to String
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Thomas G. Marshall - 29 Sep 2005 18:57 GMT
Roedy Green coughed up:

>> Hey, i need some help with creating a method that displays any long
>> using commas. example 123456 to 123,456. A easy and simple one would
>> be appreciated thank you.
> see http://mindprod.com/applet/converter.html
>
> You want to convert long to String

     The page cannot be found
     The page you are looking for might have been removed, had its name
changed, or is temporarily unavailable.

--------------------------------------------------------------------------

     Please try the following:

       a.. If you typed the page address in the Address bar, make sure that
it is spelled correctly.

       b.. Open the mindprod.com home page, and then look for links to the
information you want.
       c.. Click the  Back button to try another link.
       d.. Click  Search to look for information on the Internet.

     HTTP 404 - File not found
     Internet Explorer
Roedy Green - 30 Sep 2005 07:01 GMT
On Thu, 29 Sep 2005 17:57:26 GMT, "Thomas G. Marshall"
<tgm2tothe10thpower@replacetextwithnumber.hotmail.com> wrote or quoted

>> see http://mindprod.com/applet/converter.html
>>
>> You want to convert long to String
>
>      The page cannot be found

let me try that again
http://mindprod.com/applets/converter.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.