How to replace characters in a String?

Posted on

Question :

I have a small problem. My application receives a numeric String from the server representing a value. But the server sends, for example "100.00" and I need to put a comma in place of that point.

100.00 = > 100,00

I’d like to know how to do this in the simplest way possible. I used tutorials out there that did not help me.

    

Answer :

A “simple” option is to use the replace method of the String .

String valorComPonto = "100.00";
String valorComVirgula = valorComPonto.replace('.', ',');    

    

Leave a Reply

Your email address will not be published. Required fields are marked *