public static String PlaybackRuntimeFromMilliseconds(long milliseconds){
  long hours=0;
  long minutes=0;
  long seconds=0;
  if (milliseconds >= (1000 * 60 * 60)) {
    hours=milliseconds / (1000 * 60 * 60);
  }
  if (milliseconds >= (1000 * 60)) {
    minutes=(milliseconds % (1000 * 60 * 60)) / (1000 * 60);
  }
  if (milliseconds >= 1000) {
    seconds=((milliseconds % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
  }
  String runtime="";
  if (hours > 0) {
    runtime=String.valueOf(hours) + ":";
  }
  if (minutes > 0) {
    if (minutes < 10 && hours > 0) {
      runtime+="0";
    }
    runtime+=String.valueOf(minutes) + ":";
  }
 else {
    if (hours > 0) {
      runtime+="00:";
    }
  }
  if (seconds > 0) {
    if (seconds < 10) {
      runtime+="0";
    }
    runtime+=String.valueOf(seconds);
    if (hours < 1 && minutes < 1) {
      runtime="0:" + runtime;
    }
  }
 else {
    if (hours < 1 && minutes < 1) {
      runtime+="0:00";
    }
 else {
      runtime+="00";
    }
  }
  return runtime;
}

public static String PlaybackRuntimeFromMilliseconds ( long milliseconds ) { long hours = 0 ; long minutes = 0 ; long seconds = 0 ; if ( milliseconds >= ( 1000 * 60 * 60 ) ) { hours = milliseconds / ( 1000 * 60 * 60 ) ; } if ( milliseconds >= ( 1000 * 60 ) ) { minutes = ( milliseconds % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ) ; } if ( milliseconds >= 1000 ) { seconds = ( ( milliseconds % ( 1000 * 60 * 60 ) ) % ( 1000 * 60 ) ) / 1000 ; } String runtime = "" ; if ( hours > 0 ) { runtime = String . valueOf ( hours ) + ":" ; } if ( minutes > 0 ) { if ( minutes < 10 && hours > 0 ) { runtime += "0" ; } runtime += String . valueOf ( minutes ) + ":" ; } else { if ( hours > 0 ) { runtime += "00:" ; } } if ( seconds > 0 ) { if ( seconds < 10 ) { runtime += "0" ; } runtime += String . valueOf ( seconds ) ; if ( hours < 1 && minutes < 1 ) { runtime = "0:" + runtime ; } } else { if ( hours < 1 && minutes < 1 ) { runtime += "0:00" ; } else { runtime += "00" ; } } return runtime ; }
this will display a runtime in numerical format displaying as few leading 0 ' s as possible output example : 1 : 03 : 00 8 : 12
