title: Convert a number to 2 decimal places in Java
body: <p>I want to convert a number to a 2 decimal places (Always show two decimal places) in runtime. I tried some code but it only does, as shown below</p>
  
  <pre><code> 20.03034 &gt;&gt; 20.03
   20.3 &gt;&gt; 20.3  ( my code only rounds not converts )
  </code></pre>
  
  <p>however, I want it to do this:</p>
  
  <pre><code> 20.03034 &gt;&gt; 20.03
   20.3 &gt;&gt; 20.30 (convert it to two decimal places)
  </code></pre>
  
  <p>My code below:</p>
  
  <pre><code>angle = a variable
  angle_screen =  a variable
  
  DecimalFormat df = new DecimalFormat("#.##");
  angle = Double.valueOf(df.format(angle));
  angle_screen.setText(String.valueOf(angle) + tmp);
  </code></pre>
  
  <p>Any help on how to do this would be great, thanks.</p>