public static String formatTime(double time){
  boolean negative=false;
  if (time < 0) {
    negative=true;
    time*=-1;
  }
  int hours=(int)time / 3600;
  int minutes=(int)(time - (hours * 3600)) / 60;
  int seconds=(int)time - (hours * 3600) - (minutes * 60);
  String hoursString=hours + "";
  String minutesString=minutes + "";
  String secondsString=seconds + "";
  while (minutesString.length() < 2) {
    minutesString="0" + minutesString;
  }
  while (secondsString.length() < 2) {
    secondsString="0" + secondsString;
  }
  return (negative ? "-" : "") + (hours == 0 ? "" : hoursString + ":") + minutesString+ ":"+ secondsString;
}

public static String formatTime ( double time ) { boolean negative = false ; if ( time < 0 ) { negative = true ; time *= - 1 ; } int hours = ( int ) time / 3600 ; int minutes = ( int ) ( time - ( hours * 3600 ) ) / 60 ; int seconds = ( int ) time - ( hours * 3600 ) - ( minutes * 60 ) ; String hoursString = hours + "" ; String minutesString = minutes + "" ; String secondsString = seconds + "" ; while ( minutesString . length ( ) < 2 ) { minutesString = "0" + minutesString ; } while ( secondsString . length ( ) < 2 ) { secondsString = "0" + secondsString ; } return ( negative ? "-" : "" ) + ( hours == 0 ? "" : hoursString + ":" ) + minutesString + ":" + secondsString ; }
formats a double , in seconds , to a time string .
