Skip to content

Instantly share code, notes, and snippets.

@oluwabajio
Created April 29, 2021 00:49
Show Gist options
  • Save oluwabajio/4451a18bb4a8f589f15ebc5e2170e58d to your computer and use it in GitHub Desktop.
Save oluwabajio/4451a18bb4a8f589f15ebc5e2170e58d to your computer and use it in GitHub Desktop.
//time conversion
public String timeConversion(long value) {
String videoTime;
int dur = (int) value;
int hrs = (dur / 3600000);
int mns = (dur / 60000) % 60000;
int scs = dur % 60000 / 1000;
if (hrs > 0) {
videoTime = String.format("%02d:%02d:%02d", hrs, mns, scs);
} else {
videoTime = String.format("%02d:%02d", mns, scs);
}
return videoTime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment