title: Javafx double variable with two decimal places
body: <p>I have a variable name "unitPrice" which is double.
  if the value of unitprice = 12.23;
  it is ok and giving double precision with two decimal place.</p>
  
  <p>However if the value is unitPrice = 12.50; or unitPrice = 12.00;</p>
  
  <p>it is giving "12.5" and "12.0" 
  is there any way to make this "12.50" and "12.00" ?</p>
  
  <p>here is my code for that.</p>
  
  <pre><code>unitPrice = 12.00;
          DecimalFormat df2 = new DecimalFormat(".##");
  
      double formatDecimal = new Double(df2.format(unitPrice)).doubleValue();
  </code></pre>
  
  <p>Thanks in advance.</p>