Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:19:41+00:00 2026-06-02T11:19:41+00:00

I have a ResultSet of of Time objects that are the differences between two

  • 0

I have a ResultSet of of Time objects that are the differences between two times. They are in the minute to second range for example “00:01:12” or “00:00:22”

How do I add these java.sql.time values together to be a sum of time?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:19:51+00:00Added an answer on June 2, 2026 at 11:19 am
    public Date sumDates(String[] dateStrings, DateFormat df) {
        int secs=0, mins=0, hrs=0;
        Calendar calendar = Calendar.getInstance();
        for (int i=0; i<dateStrings.length; i++) {
            String dateString = dateStrings[i];
            Date date = (Date) df.parse(dateString);
            calendar.setTime(date);
            secs += calendar.get(Calendar.SECOND);
            mins += calendar.get(Calendar.MINUTE);
            hrs += calendar.get(Calendar.HOUR);
        }
        calendar.set(0, 0, 0, hrs, mins, secs);
        return calendar.getTime();
    }
    

    Example of usage:

    String[] dateStrings = { "00:01:12", "00:00:22" };
    DateFormat df = new SimpleDateFormat("hh:mm:ss");
    Date total = sumDates(dateStrings, df);
    System.out.println(df.format(total)); //output: 00:01:34
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that I have this resultset structure (superfluous fields have been stripped) Id |
I have a java.sql.ResultSet object containg data from a query that was run. How
I have a SelectSP which returns resultset that i am storing in the temp
I have a result of a db query in java.sql.ResultSet that needs to be
I have a factory that is supposed to create objects that inherit from class
I have several DAO objects that are used to retrieve information from a database
I have a large collection of custom objects that I have retrieved from a
It seems that ActiveRecord and Ruby's Time object doesn't play nice with times that
I have a ResultSet object containing all the rows returned from an sql query.
I'm using jdbcTemplate, and have a ResultSet consisting of about 100 named fields. And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.