Here you can find the source of sumTimes(String[] timeStrings, DateFormat df)
public static Time sumTimes(String[] timeStrings, DateFormat df)
//package com.java2s; //License from project: Apache License import java.sql.Time; import java.text.DateFormat; import java.text.ParseException; import java.util.Calendar; import java.util.Date; public class Main { public static Time sumTimes(String[] timeStrings, DateFormat df) { int secs = 0, mins = 0, hrs = 0; Calendar calendar = Calendar.getInstance(); for (int i = 0; i < timeStrings.length; i++) { String dateString = timeStrings[i]; Date date = new Date(); try { date = (Date) df.parse(dateString); } catch (ParseException e) { e.printStackTrace();//from w w w . jav a 2 s. c om } calendar.setTime(date); secs += calendar.get(Calendar.SECOND); mins += calendar.get(Calendar.MINUTE); hrs += calendar.get(Calendar.HOUR_OF_DAY); } calendar.set(0, 0, 0, hrs, mins, secs); Date d = calendar.getTime(); return Time.valueOf(df.format(d)); } }