How do I convert a String that looks like an int to the correct format? : <p>Let's say I have a String variable that looks like this.
<code>String milli = "2728462"</code> is there a way to convert it to look something like this
<code>2,252,251</code> which I guess I want as a long.</p>

<p>The thing is it will be passing strings in this format
<code>1512</code>
<code>52</code>
<code>15010</code>
<code>1622274628</code></p>

<p>and I want it to place the <code>,</code> character where it needs, so if the number is <code>1000</code> then place it like so <code>1,000</code> and <code>100000</code> then <code>100,000</code> etc.</p>

<p>How do I properly convert a String variable like that?</p>

<p>Because this</p>

<pre><code>String s="9990449935";  
long l=Long.parseLong(s);  
System.out.println(l);  
</code></pre>

<p>Will output <code>9990449935</code> and not <code>9,990,449,935</code></p>
