Calculate hour minute and second from milli seconds - Android java.util

Android examples for java.util:Date Time

Description

Calculate hour minute and second from milli seconds

Demo Code

import android.text.format.DateUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main{

    public static String getDates(long mTimeLine) {

        mTimeLine = mTimeLine / 1000;/*ww w .  j a  va 2  s. c o  m*/

        int hour = (int) mTimeLine / 3600;

        int minute = (int) (mTimeLine - (hour * 3600)) / 60;

        int second = (int) mTimeLine - (hour * 3600 + minute * 60);
        return (hour < 10 ? "0" + hour : hour) + ":"
                + (minute < 10 ? "0" + minute : minute) + ":"
                + (second < 10 ? "0" + second : second);
    }

}

Related Tutorials