Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finding difference b/n two dates in hours

 
Srikrishna DhumalRao
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two datetime formats rpt_dt_time and cur_dt_time , I want to find the difference between these dates in hours and check wether it has crossed the estimated time and act accordingly.I am working on Oracle DB and Windows 2000 OS
 
Henrique Sousa
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it would be appropriate to just give you the solution (which would be quite an amount of code), but there are a few subjects you must know in order to implement the solution:

- JDBC: Read the API and Java Tutorial on the subject. You will need it to connect and execute your queries to the Oracle DB (you will need the Oracle JDBC driver)
- Check out the java.util.Date, java.sql.Date, java.sql.Timestamp and java.util.Calendar classes, you will surely need some of them.

Then write some code and if you fail to achieve the answer to your problem we will gladly help you. Regards,

Henrique
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After looking at the Java Tutorial and API documentation, you can also take a look at these articles at www.javaworld.com:
  • Calculating Java dates
  • Working in Java time: Learn the basics of calculating elapsed time in Java
  •  
    Joe Vocioni
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If I may make a suggestion. I ran into a similar problem with an application that we were developing. The solution we chose was to calculate the difference in milliseconds.

    The reson we selected this route is if we had a scenario like;
    12-31-2002 23:59:59 and 01-01-2003 00:00:01
    -- The real time difference is only 2 seconds.

    So using the hour approach would have been inadequate in our situation.
     
    Srikrishna DhumalRao
    Greenhorn
    Posts: 17
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the reply . I am able to make up the solution
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic