Why aren't format() and parseDouble() or parseInt() compatible??

Hello, I display numbers to the user in their default locale format with:
NumberFormat.getInstance().format(number)
For example, here in the United States, I get a string with commas separating every 3 digits.
However, when the user naturally wants to use the same format in the input, then
Double.parseDouble(string), or Integer.parseInt(string)
throw exceptions, because they don't like the commas.
This is strange - shouldn't parseDouble and parseInt, accept any locale formatted strings, or, if that would be ambiguous, shouldn't there be a way to tell them what locale we are using?
I can't just delete the commas myself, because in a different locale, God-knows-what will be there.
So how do I parse a number string, in a default locale, to a double?? Thank you for any hints.
Mark

No, does not work. This only formats from the beginning of the string, leaving the end if there is junk there. So if the user input a "O" for example, instead of zero at the end, they will wonder why the number did not increase. Worse yet, if they input a legitimate string, such as 2.0e6 (which is a good way to input big numbers in a text field), that will not be formatted, but Double.formatDouble() does format it (it just does not like commas).
To the others answering, thank you for your opinions, but I want the user to be able to input the numbers the same way they are outputted. This is natural way for them to react and it would be unreasonable for me to prevent them.
As to why I don't want to strip commas myself , I already explained.

Similar Messages

  • Recently Downloaded OS X Mavericks, why aren't iWork and iLife upgrading?

    Upgraded to Mavericks, but iWork and iLife apps aren't upgrading!? WHY??!! Please help!

    Don't worry I think many people
    are experiencing apple store problems at
    the moment.
    I too have this problem with iWork and
    Aperture. All apps are reg. to me. My account
    Refused to download and gave me a broken installer
    First time around.
    Amazingly my pro apps were all unaffected.
    Still waiting on iLife and iWork to be sorted out.

  • TS3230 Why aren't Google and Yahoo loading in Safari with Maverics?  After several failed attempts, a "wireless diagnostics" zipped folder appeared on my desktop.  I'm using a macbook pro with OSX 10.9.2

    I updated to Maverics and now yahoo and google do not load in Safari - i get a "connot connect to server" warning.  other websites load just fine. 
    Also, after several attempts to access the aforementioned sites, a zipped file/folder appeared on my desktop titled "WirelessDiagnostics"
    What in the world is going on here?  I attached a screenshot of the zip file.

    Double-click anywhere in the line of text below on this page to select it, then copy it to the Clipboard by pressing the key combination command-C:
    www.google.com
    Launch the Network Utility application.
    Step 1
    Select the Lookup tab and paste into the address field (command-V). Press return. Post the output that appears below – the text, please, not a screenshot.
    Step 2
    Select the Ping tab and do the same. Please enter the same input as you did in Step 1. Don't use the output of Step 1 as input to Step 2.
    Important Note
    Some web browsers and mail clients will automatically convert a domain name such as "www.example.com" to a clickable URL, such as http://www.example.com. That will interfere with the test. If necessary, edit the input in the Network Utility window to remove any added characters.

  • Installed 4.0 - Firefox Start Page won't go away - why aren't homepage and add-ons saving?

    After installing Firefox 4.0 the Start Page and Welcome to Firefox page returns each time I start Firefox. My homepage and add-ons won't save.

    Thank you very much. I reset Firefox and it worked. I knew of MalwareBytes but had no intention of installing it before. I decided to install it anyway now and it even found 3 trojans that my Avira couldn't.
    My first instinct was to reset Firefox to it's default state but I was afraid of losing my bookmarks, cookies, site preferences etc. so I didn't even bother. Now that I saw it was my last hope, I saw there is actually a phase between clicking the "Reset Firefox" button and the action being executed. The phase explains what the button will do and asks if you agree. I did not know that and I am really happy I could keep my old stuff.
    Thanks a bunch, even if my instincts were right, I wouldn't have bothered to reset Firefox just because I'd be too lazy to get every setting back to how it was.
    Thanks again!

  • HT1351 I've encoded a vinyl LP record into digital format and recorded it onto an usb as MP3 file. But when I tried to copy it onto my ipod classic, I get a message stating "was not copied to the ipod because it cannot be played on this ipod". Why?

    I've encoded a vinyl LP record into digital format and recorded it onto an usb as MP3 file. But when I tried to copy it onto my ipod classic, I get a message stating "was not copied to the ipod because it cannot be played on this ipod". Why?

    I was refering to the "sample rate", normally 44.1 KHz, the iPod might not be able to play tracks with a non-standard rate. Otherwise I'm not sure what the issue might be.
    tt2

  • HT204406 I used Match, and now there are artists missing when I search by artist, yet they are in my library when I search by song. If they are in many song list,  why aren't they in my artist list? Also I can't sort my songs by artist on iPhone,  so thes

    I used Match, and now there are artists missing when I search by artist, yet they are in my library when I search by song. If they are in many song list,  why aren't they in my artist list? Also I can't sort my songs list by artist on iPhone,  so their music is basically lost in space....help

    It's not clear from your post, but you do realise
    that if you import a cd as a compilation, it will not
    appear under artists? This is done to save the iPod
    being cluttered up with single artists entries who
    might have only one song listed.
    I wasn't aware of that. It's true that I haven't been using the "compilation" tag for a long time. I've only started using it with iTunes 7 as otherwise with Coverflow I would have one album cover for each artist in a compilation. Before that my compilations weren't tagged as such as that is quite probably why each artist from compilations showed up when browsing by artists.
    Message was edited by: Didou

  • Why aren't my clips evident in my event? My project icons are there and the media IS in the event. I see it on the hard drive. HELP!

    Why aren't my clips evident in my event? My project icons are there and the media IS in the event. I see it on the hard drive. HELP!
    It is the strangest thing. I click on the project and it is there with all the stuff and cuts, etc., but no clips in the event!
    Thank you.

    You u r right.
    Thanks I figured it out. It was the sort by preference toggle UP TOP for clips. I was fabulously ignorant of it till this AM. Thank you very much for answering. 
    Mike S

  • Why aren't my scanned photos showing up in iphoto? I have an HP scanner with the option to import directly to iphoto. It says "sending to destination" but it never gets to iphoto. I scanned hundreds of photos several months and it worked fine - now it won

    Why aren't my scanned photos showing up in iphoto? I have an HP scanner with the option to import directly to iphoto. It says "sending to destination" but it never gets to iphoto. I scanned hundreds of photos several months and it worked fine with the photos going directly into iphoto - now it won't work. Any suggestions?

    As the feature is part of your scanner set up nd not iPhoto, you'd need to ask the makers of that for help.
    Regards
    TD

  • HT4236 Why will my iPod not sync all the photos I want it to - I get a message saying that it cant display certain images.  All my photos are in jpg format and similar size.

    Why will my iPod touch not sync all the photos I want it to.  I get a message saying it cant display some of my photos.  They are all in jpg. format and similar size. Never had any problems before!
    Thanks

    That sounds exactly like an issue that has plagued McAfee users for around a year.
    Try disabling email scanning in your anti virus program.

  • I just purchased a mac air. Why aren't numbers, keynote and pages free, I just purchased a mac air. Why aren't numbers, keynote and pages free

    I just purchased a mac air in Feb 2014.  Why aren't numbers, keynote and pages available for free download?

    kizoby wrote:
    I just purchased a mac air in Feb 2014.
    See Here >  http://www.apple.com/creativity-apps/mac/up-to-date/

  • Why aren't my iPad and iPhone syncing on iCloud?

    Why aren't my iPhone and iPad syncing on iCloud? All settings are on.

    settings->icloud
    and
    settings->itunes & app stores
    make sure the correct appleid is set if not logout and login with the correct

  • Why has paste stopped including formatting and images?

    I am pasting text and images from a PDF or Web pages and when I paste into Word or Evernote, etc my Macbook no longer does the default paste with formatting and loses the images too. I've tried cmd-v, edit>paste, all forms of paste but nothing gives me the old default of paste with formatting and images. I'm getting text with some formatting like bold etc, but all the layout it lost, line breaks, etc. it'a juat one block of tect. This used to work properly before upgrading to Mountain Lion. Is there a fix? I just want to paste WITH FORMATTING AND IMAGES.

    From which Web Browser?
    Appears to work correctly from Safari:
    Copy and pasted into Word:
    MtD
    Message was edited by: Meg The Dog to fix typo

  • Why aren't Calendar categories colored in month view

    On the iPhone 5S under iOS 7.0.4 in the Calendar app, in the month view, existting daily events are indicated by gray dots.  Why aren't these dots colored according to the event category?  My recollection is that used to be the case prior to iOS 7.0.  In day or week view, the time or full day are showing the respective category color.  And on the iPad Air, under iOS 7.0.4, the calendar month view DOES show the category color in the dot! Did Apple forget about this functionality?  I can see there is an event, but not the categories I used (medical, travel, etc).

    Comparing this functionality between a larger format such as the iPad and the smaller format on the iPhone is a little like apples and oranges. The iPad in Month view has enough space on each day to show discrete entries - and can consequently show them in their respective calendar colors.On the Phone, it only has space to indicate that one or more events exist (represented by a single dot). If you have more than one event, in different categories, which category color should it display?

  • Backed Up itunes/Re-Formatted/ and Now No Purchased Music Playlist

    i did a back up of 1886 songs (something around 200 purchased itunes tracks included) then re-formatted.
    being new to re-formatting, turns out i only did my C drive where my itunes libray is not (not needing to do my F drive)but i do think i had a part of itunes there because wiping out C drive; going back to my itunes everything was gone.
    i wasn't worried, i just did "add folder to libray" from F drive.....and there it was, all my tunes were back BUT no playlists. that's ok but why aren't my purchased tracks showing up ? they are there but no organized in the green playlist.
    how can i get them back in there so i know what i bought ?
    thank u for any help.
    Dave.

    The next time you purchase anything, iTunes will re-create that playlist. In the meantime, you can simply re-build it by using a smart playlist with the following: "Kind contains protected AAC". Once you make your next purchase & the purchased playlist is re-built, you can simply drag/drop your smart playlist into the purchased, combining the 2. Once you're sure everything is back in the purchased list, you can delete your smart playlist. Hope this helps.

  • Please help. Why aren't my hyperlinks moving over from one document to another?

    Firstly I'm using Adobe InDesign 5.5
    I have document A, which has over 50 pages.
    Then document B, with over 40 pages.
    All the pages on document B, I want to 'move' over to document A, so document A will now have 90 pages and I'll no longer need document B. The issue is, when I move the pages over, the hyperlinks I have throughout document B don't move over (which there are over 30 hyperlinks on certain sections of certain pages).
    Now it seems like the only 'slow/safe' process of doing this, is to copy page 1&2 of Document B, and then 'paste in place' on document A, and then go back to B and copy pages 3&4. this is a long process...considering I have over 2,500 pages to get through.
    Why aren't the hyperlinks moving over? When I go back to document A, I click on the hyperlink tab and it's blank.
    It's really annoying and I'm trying to figure out why this is even happening and can't find any solution online.

    You should save both documents before doing that with Save as into the same folder, so thel links will not change.
    I would recommend to package your files after doing that.

Maybe you are looking for

  • Cursors remained open after closing connection

    I am using OC4J 10g (Application Server) and Oracle10g DB. OC4J is maintaining the connection pool(com.evermind.sql.DriverManagerDataSource). I get the connection from pool and call DB procedure, then close resultset, statement and connection. It clo

  • ITunes has stopped launching when I plug in my iPhone via USB

    Two things have stopped working with my iPhone recently. 1.  iTunes no longer launches automatically when I plug in my iPhone to my iMac via USB. 2.  The iPhone Notes app has stopped syncing via USB lead between the iPhone and the iMac. I have tried

  • Photoshop CS will not open after upgrade to OSX 10.4.3

    Photoshop CS will not open in my iBook after an upgrade from 10.3.9 to 10.4.4. Even when I reinstall, from a dmg file, it doesn't help. The error message says: "the app photoshop quit unexpectedly" My iBook, which boots in 10.3.9 still, has no proble

  • Replying to Meeting Requests (Calendar)

    In regard to Calendar on the iPod/iPhone/iPad: Is there any way to Decline a meeting request and Edit the reply so that you can explain WHY you're declining the meeting? I know you send a separate reply but whenever I click Decline, it immediately se

  • End of Template not rendering

    I have created a Lower 3rd template in Motion where a bar and text slides onto screen, displays for 8 sec, then slides off the way it came. I have saved the project as a template and then used the template in a FCP project. When viewing the Lower 3rd