Format double value to 2 decimal points and get comma separated currency format in Java
<p>I'm working on project where I have to display price in following format.</p>

<pre><code>250  -&gt; 250.00
2500 -&gt; 2,500.00
260500.33 -&gt; 260,500.33
</code></pre>

<p>I though following approach gonna make this work but It's not working.</p>

<pre><code>    double price = 2500;
    DecimalFormat df = new DecimalFormat("#.00");

    String format1 = df.format(price);
    System.out.println(format1); //250.00

    String format2 = NumberFormat.getNumberInstance(Locale.US).format(format1);// Exception "Cannot format given Object as a Number"
    System.out.println(format2); //excepted 2,500.00
</code></pre>

<p>What am i doing wrong ?</p>