title: millis string format in java
body: <p>I have this code:</p>
  
  <pre><code>  public String calculateHoursFromMilliSeconds(long totalMilliSeconds) {
          long totalSeconds = totalMilliSeconds / 1000;
          long milli = totalMilliSeconds % 1000;
          long hours = totalSeconds / 3600;
          long minutes = (totalSeconds % 3600) / 60;
          long seconds = totalSeconds % 60;
          return String.format("%02d:%02d.%03d", hours, minutes, seconds, milli);
      }
  </code></pre>
  
  <p>however </p>
  
  <p>for input 412 millis</p>
  
  <p>i get output <code>00:00.004</code> instead of <code>00:00.412</code></p>
  
  <p>for input 60412 millis</p>
  
  <p>i get output <code>01:00.004</code> instead of <code>01:00.412</code></p>