Skip to content

Commit

Permalink
Changed time format
Browse files Browse the repository at this point in the history
  • Loading branch information
praharshjain committed May 18, 2017
1 parent d4e01ec commit e0664b5
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,17 @@ public String getElapsedTime() {
}
// Get remaining time
public String getRemainingTime() {
if(remainingTime==-1) return "Unknown";
if(remainingTime<0) return "Unknown";
else return formatTime(remainingTime);
}
// Format time
public String formatTime(long time) { //time in seconds
String s="";
if(time>=3600) {
s+=(time/3600)+" hours";
time%=3600;
}
if(time>=60) {
s+=" "+(time/60)+" minutes";
time%=60;
}
if(time>0) {
s+=" "+time+" seconds";
}
s+=(String.format("%02d", time/3600))+":";
time%=3600;
s+=(String.format("%02d", time/60))+":";
time%=60;
s+=String.format("%02d", time);
return s;
}
// Get this download's progress.
Expand Down

0 comments on commit e0664b5

Please sign in to comment.