int To Hour Min - Android java.util

Android examples for java.util:Hour

Description

int To Hour Min

Demo Code


//package com.java2s;
import android.text.TextUtils;

public class Main {
    public static String intToHourMin(long timing) {
        String finalString = "";
        if (timing - (60 * 60 * 1000) > 0) {
            //We have been running for more than an hour. Calculate hours:
            int hours = (int) Math.floor(timing / (60 * 60 * 1000));
            finalString += Integer.toString(hours) + " Hr ";
            timing -= (60 * 60 * 1000) * hours;
        }/*w  ww  . j  a  va2 s .c  o  m*/
        if (timing - (60 * 1000) > 0) {
            //We have been running for more than a minute. Calculate minutes:
            int minutes = (int) Math.floor(timing / (60 * 1000));
            finalString += Integer.toString(minutes) + " Min ";
            timing -= (60 * 1000) * minutes;
        } else if (!TextUtils.isEmpty(finalString)) {
            finalString += "0 Min";
        }
        return finalString;
    }
}

Related Tutorials