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
AneeshaAneesha 

How to convert a comma seperated string into integer

Hi,

 

I need to convert a comma seperated string, say 34,987 into a number 34987. How do I remove the comma in an apex class?

Best Answer chosen by Admin (Salesforce Developers) 
Amitkumar15Amitkumar15

try this..

 

 

.replaceAll(" ,$", "")

All Answers

Amitkumar15Amitkumar15

try this..

 

 

.replaceAll(" ,$", "")

This was selected as the best answer
AneeshaAneesha

Thanks Amitkumar

AneeshaAneesha
Could you please tell me how to recreate the comma seperated string from the integer?
PriyasoftPriyasoft

Try this....

 

string strSample = '37,8945';
Integer Replaced = Integer.Valueof(strSample.replace(',', ''));