This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes finding difference b/n two dates in hours Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "finding difference b/n two dates in hours" Watch "finding difference b/n two dates in hours" New topic
Author

finding difference b/n two dates in hours

Srikrishna DhumalRao
Greenhorn

Joined: Oct 05, 2004
Posts: 17
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


srikrishna
Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92
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

Joined: Dec 17, 2003
Posts: 624

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

    Joined: Sep 28, 2004
    Posts: 3
    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

    Joined: Oct 05, 2004
    Posts: 17
    Thanks for the reply . I am able to make up the solution
     
    Don't get me started about those stupid light bulbs.
     
    subject: finding difference b/n two dates in hours
     
    Similar Threads
    Dates
    How to calculate difference between two dates in months
    DATE SUBRACTION
    difference between two dates
    DateDiff Function in Java?