Format time int value as mm:ss - Android java.util

Android examples for java.util:Time

Description

Format time int value as mm:ss

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.GregorianCalendar;

public class Main {
    public static String timeMMSS(int second) {
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTimeInMillis(second * 1000);
        SimpleDateFormat format = new SimpleDateFormat("mm:ss");
        String time = format.format(gc.getTime());
        return time;
    }//from ww w .  j  av  a2  s . com
}

Related Tutorials