public static String seconds2time(long seconds){
  long minutes=seconds / 60;
  seconds=seconds - minutes * 60;
  long hours=minutes / 60;
  minutes=minutes - hours * 60;
  long days=hours / 24;
  hours=hours - days * 24;
  StringBuilder time=new StringBuilder();
  if (days != 0) {
    time.append(Long.toString(days));
    time.append(":");
    if (hours < 10)     time.append("0");
  }
  if (days != 0 || hours != 0) {
    time.append(Long.toString(hours));
    time.append(":");
    if (minutes < 10)     time.append("0");
  }
  time.append(Long.toString(minutes));
  time.append(":");
  if (seconds < 10)   time.append("0");
  time.append(Long.toString(seconds));
  return time.toString();
}

public static String seconds2time ( long seconds ) { long minutes = seconds / 60 ; seconds = seconds - minutes * 60 ; long hours = minutes / 60 ; minutes = minutes - hours * 60 ; long days = hours / 24 ; hours = hours - days * 24 ; StringBuilder time = new StringBuilder ( ) ; if ( days != 0 ) { time . append ( Long . toString ( days ) ) ; time . append ( ":" ) ; if ( hours < 10 ) time . append ( "0" ) ; } if ( days != 0 || hours != 0 ) { time . append ( Long . toString ( hours ) ) ; time . append ( ":" ) ; if ( minutes < 10 ) time . append ( "0" ) ; } time . append ( Long . toString ( minutes ) ) ; time . append ( ":" ) ; if ( seconds < 10 ) time . append ( "0" ) ; time . append ( Long . toString ( seconds ) ) ; return time . toString ( ) ; }
converts a value in seconds to : " d : hh : mm : ss " where d = days , hh = hours , mm = minutes , ss = seconds , or " h : mm : ss " where h = hours < 24 , mm = minutes , ss = seconds , or " m : ss " where m = minutes < 60 , ss = seconds
