关于两个时间(00:00:00)相加的实现方法
timeList={"00:20:00","00:23:43"};
public static String getTotal(String[] timeList) {
String timeString = null;int hour = 0;
int min = 0;
int sec = 0;
for (int i = 0; i < timeList.length; i++) {
timeString = timeList[i];
int firstIndex = timeString.indexOf(':');
int secondIndex = timeString.lastIndexOf(':');
hour += Integer.parseInt(timeString.substring(0, firstIndex));
min += Integer.parseInt(timeString.substring(firstIndex + 1,
secondIndex));
sec += Integer.parseInt(timeString.substring(secondIndex + 1,
timeString.length()));
}
int secToMin, sec2;
int minToHour, min2;
if (sec > 60) {
secToMin = (sec / 60);
sec2 = (sec % 60);
min = min + secToMin;
}
if (min > 60) {
minToHour = (min / 60);
min2 = (min % 60);
hour = hour + minToHour;
}
String hString;
String mString;
String string;
if (hour < 10) {
hString = "0" + String.valueOf(hour);
} else {
hString = String.valueOf(hour);
}
if (min < 10) {
mString = "0" + String.valueOf(min);
} else {
mString = String.valueOf(min);
}
if (sec < 10) {
string = "0" + String.valueOf(sec);
} else {
string = String.valueOf(sec);
}
return hString + ":" + mString + ":" + string;
}