Below I have a List of Time to be added together
List<String> arrTime = new ArrayList<String>(); int hour = 0; int minutes = 0; int seconds = 0; String Nmin = null; String Nsec = null; String result = null; arrTime.add("09:05:25"); arrTime.add("09:30:15"); arrTime.add("10:15:01"); arrTime.add("08:19:49"); arrTime.add("09:17:40"); for (Iterator itr = arrTime.iterator(); itr.hasNext();) { String Time = (String) itr.next(); if (Time != null) { String[] rowtime = Time.split(":"); hour += Integer.parseInt(rowtime[0]); minutes += Integer.parseInt(rowtime[1]); seconds += Integer.parseInt(rowtime[2]); } } hour += minutes/60; minutes += seconds/60; minutes %= 60; seconds %= 60; if (minutes < 10) Nmin = "0" + String.valueOf(minutes); else Nmin = String.valueOf(minutes); if (seconds < 10) Nsec = "0" + String.valueOf(seconds); else Nsec = String.valueOf(seconds); result = hour + ":" + Nmin + ":" + Nsec; System.out.println(result);
Output
46:28:10