Format Time duration in format 00:00 - Android java.util

Android examples for java.util:Date Time

Description

Format Time duration in format 00:00

Demo Code

public class Main {

  public static String getFormatTime(int duration) {
    int min = 0;// w  ww.  j  a  va 2 s  .  c  om
    int sec;

    sec = duration / 1000;
    if (sec > 60) {
      min = sec / 60;
      sec = sec % 60;
    }
    return String.format("%02d:%02d", min, sec);
  }

}

Related Tutorials