String temp = "";
temp = String.format("%02d", ""+hour)+":"+String.format("%02d", ""+min)+":"+String.format("%02d", ""+sec);
Is this the fastest way to format the numbers with concatenation to specify leading zeroes, or is there another way?
I have to display the String in the format 00:00:00. The hour, min, and sec are int va开发者_如何学Pythonriables which start from 0 and are put into the Thread which counts the time elapsed and displays this time accordingly. Is this the correct way, or is there any better way?
Try this. I assume that hour, min and sec are ints.
String temp = "";
temp = String.format("%02d:%02d:%02d", hour, min, sec);
精彩评论