comma « decimal « Java Data Type Q&A

1. best way to parseDouble with comma as decimal separator?

String p="1,234";
Double d=Double.valueOf(p); 
return a error. what the besy way to get 1.234 ? better than: p=p.replaceAll(",","."); thanks a lot :)

3. Why is it such a pain to use java in a country that uses commas as decimal?

Why is it such a pain to use java in a country that uses commas as decimal separator? A few weeks back I've asked here about the keypad decimal key. For some reason, java doesn't map the decimal key to a comma on the Portuguese (Portugal) keyboard layout. I've got no answer and I ended up using a custom plainDocument on ...

4. Comma instead of decimal point

Thanks. Writing code internally is no problem with a dot. Will the locale of my computer determine the string output style automatically? I saw examples of using a NumberFormatter, but then I assume I have to use it every time I output to a string with each individual number. I was hoping for a more global method.

5. How to use comma instead of dot as decimal seperator

Hi, In my application, there is a field "currency" and i had to ensure that the value entered in currency field is always "numeric". I did this by checking for "NumberFormatException" when the value is parsed. This is not working when the currency is entered as 22,21 instead of 22.21, as is done in some countries,i.e, comma is used instead of ...