title: Java format hour and min
body: <p>I need to format my time string such as this: </p>
  
  <pre><code>int time = 160;
  </code></pre>
  
  <p>Here's my sample code:</p>
  
  <pre><code>public static String formatDuration(String minute) {
      String formattedMinute = null;
      SimpleDateFormat sdf = new SimpleDateFormat("mm");
      try {
          Date dt = sdf.parse(minute);
          sdf = new SimpleDateFormat("HH mm");
          formattedMinute = sdf.format(dt);
      } catch (ParseException e) {
          e.printStackTrace();
      }
      return formattedMinute;
  //        int minutes = 120;
  //        int h = minutes / 60 + Integer.parseInt(minute);
  //        int m = minutes % 60 + Integer.parseInt(minute);
  //        return h + "hr " + m + "mins";
  }
  </code></pre>
  
  <p>I need to display it as 2hrs 40mins. But I don't have a clue how to append the "hrs" and "mins". The requirement is not to use any library.</p>
  
  <p>If you've done something like this in the past, feel free to help out. Thanks a bunch!</p>