title: Round up in 30 min (nearest half-hour) increments:
body: <p>What is the most efficient way (in Java)  to round an integer in 30 increments. My output will be an Integer:</p>
  
  <p>Here is my code that returns minutes in integer.</p>
  
  <pre><code>long different = endTime.getTime() - startTime.getTime();
  int idiff = TimeUnit.MILLISECONDS.toMinutes(different) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(different));
  </code></pre>
  
  <p>Now I want to round up this integer. For example: </p>
  
  <blockquote>
    <p>Any number &lt;= 30 = round up to 30: </p>
    
    <p>Any number between 31 to 60 = round up to 60</p>
    
    <p>Any number between 61 to 90 = round up to 90 </p>
    
    <p>Any number between 91 to 120 = round up to 120</p>
    
    <p>Any number between 121 to 150 = round up to 150</p>
  </blockquote>