Reputation: 5905
I know here is lot of question on "start/stop timer".But i am looking for format of
timer. I am developing one recording application which show record time.
I able to show time in second format like 1 2 3 4 5. but i need to show this time like
00.01. I need some hint or reference. here is image which i need to show.
Thanks in Advance
Upvotes: 0
Views: 495
Reputation: 4489
Here is the very nice tutorial of simple countdown timer. Go through it and you will be able to achieve what you want.
Or A Stitch in Time is the efficient way to implement the stop watch type app from developer.android.com and yes it uses the format you required.
Upvotes: 3
Reputation: 18670
You can try this:
private String stringForTime(int timeMs) {
StringBuilder mFormatBuilder = new StringBuilder();
Formatter mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
int totalSeconds = timeMs / 1000;
int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int hours = totalSeconds / 3600;
mFormatBuilder.setLength(0);
if (hours > 0) {
return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
} else {
return mFormatter.format("%02d:%02d", minutes, seconds).toString();
}
}
Upvotes: 1