Results 1 to 2 of 2
- 11-02-2011, 05:50 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
Getting/changing the decimal symbol?
I have a string containing a decimal number. But if I convert it to a float or double, the decimal symbol will either be be ignored or the method throw a NumberFormatException (I'm not sure which one) if the program is run on a machine with a different decimal symbol specified in the settings than what is used in the string, right?
So, I thought I could either detect what decimal symbol the system uses and replace the one in the string with that, or for that internally change the setting itself, using the System.getProperty(String), which I had previously used for things like the new line character(s) and path separator. There doesn't seem to be a property for the decimal symbol though.
I'm guessing there is a way to do this(because internationalization is important for most anything related to computers), but... how? I don't want to seem like the guy who just jumps in and demands someone else to write the code for him, but I have no idea how to do this.
- 11-02-2011, 06:17 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: Getting/changing the decimal symbol?
If you have done simple wrapper conversion with the dot symbol as the decimal point it returns the same regardless of the decimal symbol you have set in the system.
However, there are ways to we can consider the localizations.Java Code:String strVal = "12.23"; System.out.println(Double.parseDouble(strVal));
Similar Threads
-
anyone know's how to program a conversion of binary-decimal , decimal-binary
By irnie1994 in forum JCreatorReplies: 5Last Post: 08-25-2011, 07:32 PM -
Decimal to binary, octal to decimal
By matejm1994 in forum New To JavaReplies: 3Last Post: 12-26-2010, 09:59 AM -
Changing binding when changing the underlying model object
By ChrisNY in forum NetBeansReplies: 0Last Post: 08-14-2010, 10:09 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks