public static final String getFormattedTime(long timeleft) {

    String formattedTime = null;

    if (timeleft <= 0)
      formattedTime = String.format("%02d:%02d:%02d", 0, 0, 0);
    else {
      final long hours = TimeUnit.MILLISECONDS.toHours(timeleft);

      final long minutes = TimeUnit.MILLISECONDS.toMinutes(timeleft
        - TimeUnit.HOURS.toMillis(hours));

      final long seconds = TimeUnit.MILLISECONDS.toSeconds(timeleft
        - TimeUnit.HOURS.toMillis(hours) - TimeUnit.MINUTES.toMillis(minutes));

      formattedTime = String.format("%02d:%02d:%02d", hours, minutes, seconds);
    }

    return formattedTime;
  }
public static final String getFormattedTime ( long timeleft ) { String formattedTime = null ; if ( timeleft <= 0 ) formattedTime = String . format ( "%02d:%02d:%02d" , 0 , 0 , 0 ) ; else { final long hours = TimeUnit . MILLISECONDS . toHours ( timeleft ) ; final long minutes = TimeUnit . MILLISECONDS . toMinutes ( timeleft - TimeUnit . HOURS . toMillis ( hours ) ) ; final long seconds = TimeUnit . MILLISECONDS . toSeconds ( timeleft - TimeUnit . HOURS . toMillis ( hours ) - TimeUnit . MINUTES . toMillis ( minutes ) ) ; formattedTime = String . format ( "%02d:%02d:%02d" , hours , minutes , seconds ) ; } return formattedTime ; }
/*
Returns time in the custom format HH:mm:ss (e.g.: a value of more than 24
hours is allowed for the field HH )