Implementation of adding two time points (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;
}