Skip to Main Content

Java SE (Java Platform, Standard Edition)

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!

Subtract date,time using Calendar() or Date()

843810Sep 13 2004 — edited Sep 20 2006
Hello everybody. I created a JFrame application connecting to Ms SQL server. I want to subtract the days and the total time in hours,minutes,secs. I was wondering if there are already build-functions in Calendar() class or in Date() class to subtract dates and times at once.

For example, let say that we have Date 13/09/2004 and time=15:09:03 and I would like to subtract from them the Date 14/09/2004 and time= 02:11:01.Is any function pre-build to simply output the result Final Time 11 hours 1 minutes and 58 seconds?Or do I have to calculate them manually?

I read both API classes and the only interesting I found was to convert both times in miliseconds and then convert the final one in time again.

I really appreciate any help.Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2006
Added on Sep 13 2004
3 comments
218 views