3
I need this string to come out in 00:00:00 format currently it comes out: 5:4:1 for example, what I did was to do several ifs, but it is not efficient, and also it does not format when the 3 are below 10:
long diffSeconds2 = long_hours / 1000 % 60;
long diffMinutes2 = long_hours / (60 * 1000) % 60;
long diffHours2 = long_hours / (60 * 60 * 1000) % 24;
if (long_hours > 0) {
if(diffSeconds2<10){
str_testing = diffHours2 + ":" + diffMinutes2 + ":0" +diffSeconds2;
}else if(diffMinutes2<10){
str_testing = diffHours2 + ":0" + diffMinutes2 + ":" +diffSeconds2;
}else if(diffHours2<10){
str_testing = "0" + diffHours2 + ":" + diffMinutes2 + ":" +diffSeconds2;
}
//e se for os 3 abaixo de 10 teria que ficar: 00:00:00
That’s what I was looking for, thank you.
– Igor Oliveira