Convert Time in seconds to hour and minutes - Android java.util

Android examples for java.util:Date Time

Description

Convert Time in seconds to hour and minutes

Demo Code

import android.net.Uri;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.StrikethroughSpan;
import android.util.Log;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{


    public static String getTalkTime(int time) {
        int hour = time / 3600;
        int minu = (time % 3600) / 60;
        int sec = time % 60;
        String str = "";
        if (hour == 0) {
            str = String.format("%02d:%02d", minu, sec);
        } else {/*  w ww  .j  av  a2s  .c om*/
            str = String.format("%02d:%02d:%02d", hour, minu, sec);
        }
        return str;
    }

}

Related Tutorials