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;//from  ww w .  ja  v a 2s. c o m
    int sec;

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

}

Related Tutorials