format Time using String.format - Android java.util

Android examples for java.util:Date Time

Description

format Time using String.format

Demo Code


//package com.java2s;

public class Main {
    public static String formatTime(long millis) {
        int seconds = (int) (millis / 1000) % 60;
        int minutes = (int) ((millis / 1000) / 60);

        return String.format("%02d : %02d",
                new Object[] { minutes, seconds });
    }// ww w.  j  av a 2s. c  o  m
}

Related Tutorials