About this question
See I'm getting this field from an integration with wookie, and the field should go to Salesforce in currency format. I get it with the following value: BRL 20.000,00 (Twenty thousand reais)I need to treat this value, removing the letters, removing the "." and replacing the "," with "." The final result should be a decimal 20000.00 So far I'm:
//With this line I get the result I want
acc.Capital_Social__c= Decimal.valueOf((String.valueOf(results.get('capital_social')).replaceAll('[^0-9,]', '')).replace(',', '.'));
The problem is that before I implemented this solution, this was the code used:
acc.Capital_Social__c = Decimal.valueOf(String.valueOf(results.get('capital_social')).substring(3).remove('.').replace(',', '.'));
You will notice that I stopped using the function
.substring(3)
acc.Capital_Social__c= Decimal.valueOf((String.valueOf(results.get('capital_social')).replaceAll('[^0-9,.]', '')).substring(3).remove('. ').replace(',', '.'));Because when I put it the result generated is: 0.00
I don't understand why I get this result. I don't understand what this ".substring(3)" function was doing in the old code, on google I didn't enter an explanation about this function. I'm afraid that she will be missed at some point. I would like to know if anyone knows this function, if they understand its purpose, if it is really needed, and why it is returning 0.00