function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Invalid Double exception when parsing comma in string

It looks like the Double.valueOf(String) and Decimal.valueOf(String) don't support using a non-decimal point separator. For many locales, the decimal separator character is the comma (,) instead of period (.). When I call Double.valueOf(String) in a locale that uses a comma, I expect it to parse correctly. Unfortunately, this isn't the case.


For example, the following code will throw a TypeException:


Double d = Double.valueOf('7,2');
System.debug('D=' + d.format());


Changing the "," to "." works though.



Is this expected behavior? I'm guessing the only thing I can do is replace "," with "." whenever parsing a string. :smileysad: