Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Time addition/subtraction in Java

807606Mar 9 2007 — edited Mar 9 2007
Hi guys any help really appreciated as this is doing my head in (and I'm sure its something obvious)

Am trying to work out the difference in two times
public Time getFlightTime()
    {
        long diff = arTime.getTimeInMillis() - depTime.getTimeInMillis();
        
        Calendar temp = Calendar.getInstance();
        temp.setTimeInMillis(diff);
        return temp;
        
    }
have tried it with date and time creating the return object and it always ends up 59 mins out. Have had the function being called above print out "diff" and the time in milliseconds corresponds to the time it should be - ie 59 mins less than what it actually returns.

Any help - please?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 6 2007
Added on Mar 9 2007
10 comments
594 views