Solved

Java/JSP add Time

Posted on 2007-03-28
1
422 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:
mayankeagle 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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 …

758 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

21 Experts available now in Live!

Get 1:1 Help Now