title: Java : Rounding a decimal value to HALF_EVEN
body: <p>I have been trying to write a java code to Round a value to the below requirement.</p>
  
  <p>If x=63.88 => roundedValue= 64.00;</p>
  
  <p>If x=63.50 => roundedValue= 64.00</p>
  
  <p>If x=63.32 => roundedValue= 63.32</p>
  
  <p>I tried with the different roundingModes like CEILING, DOWN, FLOOR, HALFDOWN.
  I also tried Math.round();</p>
  
  <p>But I'm unable to get the expected output.
  My input is a string and output is a string.</p>
  
  <p>Please find the code snippet I tried below</p>
  
  <pre><code>BigDecimal value1 = new BigDecimal(input);
  value1=value1.setScale(2, RoundingMode.HALF_EVEN);
  //float rounded=Math.round(amount);
  
  String finalValue=String.valueOf(value1);
  </code></pre>
  
  <p>I'm unable to get the desired output. Please let me know how to achieve this?</p>
  
  <p>ps: should i consider using float or BigDecimal??</p>