Solved

Java/JSP add Time

Posted on 2007-03-28
1
424 Views
Last Modified: 2013-11-23
Hi there

I have a variable in my SQL DB called 'calllength' of type 'time' in the format: 00:05:12 and I want to add up all these totals to give me a total time. How do i go about doing this?

The main problem is that I dont know what type of variable to make it as, and how to essentially add the times. I have tried a few things but mainly get the incompatible types error message. Heres my code:

rs = stmt.executeQuery("select * from calldata c, extensions e where c.receiving = e.extension and calldate = '2007-03-21'");
      while (rs.next()){      
      
      %>
            <TR>
                  <Td  bgcolor="#ffffff" align=center><%=rs.getString("c.inout")%></td>
                  <Td  bgcolor="#ffffff" align=center><%=rs.getString("c.calldate")%></td>
                  <Td  bgcolor="#ffffff" align=center><%=rs.getString("c.calltime")%></td>
                  <Td  bgcolor="#ffffff" align=center><%=rs.getTime("c.calllength")%></td>
                  <Td  bgcolor="#ffffff" align=center><%=rs.getString("c.incoming")%></td>  
                  <Td  bgcolor="#ffffff" align=center><%=rs.getString("c.receiving")%></td>
                  <Td  bgcolor="#ffffff" align=center><%=rs.getString("e.Name")%></td>
                  <Td  bgcolor="#ffffff" align=center><%=rs.getString("c.number")%></td>  
            </tr>
      <%       
                }
       con.close();

Thanks in advance
0
Comment
Question by:AndriesKeun
1 Comment
 
LVL 30

Accepted Solution

by:
Mayank S earned 125 total points
ID: 18809174
Probably use the Calendar class and the add () method:

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html#add(int,%20int)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now