Android Second to Time milliSecondsToTimer(long milliseconds)

Here you can find the source of milliSecondsToTimer(long milliseconds)

Description

milli Seconds To Timer

Declaration

public static String milliSecondsToTimer(long milliseconds) 

Method Source Code

//package com.java2s;

public class Main {
    public static String milliSecondsToTimer(long milliseconds) {
        String totalTime = "";
        String totalSeconds = "";
        String totalMinutes = "";

        int hours = (int) (milliseconds / (1000 * 60 * 60));
        int minutes = (int) (milliseconds % (1000 * 60 * 60)) / (1000 * 60);
        int seconds = (int) ((milliseconds % (1000 * 60 * 60))
                % (1000 * 60) / 1000);//  w ww.ja va 2s. c o m

        if (hours > 0) {
            if (hours < 10) {
                totalTime = "0" + hours + ":";
            } else {
                totalTime = hours + ":";
            }
        }

        // Prepending 0 to seconds if it is one digit
        if (seconds < 10) {
            totalSeconds = "0" + seconds;
        } else {
            totalSeconds = "" + seconds;
        }

        if (minutes < 10) {
            totalMinutes = "0" + minutes;
        } else {
            totalMinutes = "" + minutes;
        }

        totalTime = totalTime + totalMinutes + ":" + totalSeconds;

        // return timer string
        return totalTime;
    }
}

Related

  1. intSecondsToStringMinSec(int input)
  2. getTimeRemaining(long durationInMilliseconds)
  3. timeRemaining(double seconds)
  4. getDfferenceInMinute(long miliseconds)
  5. getTimeForm(long milliseconds)
  6. getTime(int minutes, int seconds)
  7. getElapsedSeconds(long start, long end)
  8. getSpeedString(float bytesPerMillisecond)
  9. getSeconds1()