Java TimeUnit Usage getDurationHMS(long millis)

Here you can find the source of getDurationHMS(long millis)

Description

get Duration HMS

License

Apache License

Declaration

public static String getDurationHMS(long millis) 

Method Source Code

//package com.java2s;
/*//from   w w w.ja  v  a 2  s. c  o m
 * copyright (C) 2013 Christian P Rasmussen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.concurrent.TimeUnit;

public class Main {
    public static String getDurationHMS(long millis) {
        String hms = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis),
                TimeUnit.MILLISECONDS.toMinutes(millis)
                        - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
                TimeUnit.MILLISECONDS.toSeconds(millis)
                        - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
        return hms;
    }
}

Related

  1. getDurationBreakdown(long millis)
  2. getDurationBreakdown(long millis)
  3. getDurationFromMillis(long millis)
  4. getDurationFromMilliseconds(long duration)
  5. getDurationFromTwoDates(Date startTime, Date endTime)
  6. getDurationUnit(Map config)
  7. getElapsedTime(Date start, Date end)
  8. getElapsedTimeString(long elapsed)
  9. getETA(final long seconds)