Click to See Complete Forum and Search --> : time question


lindawqu
August 2nd, 2001, 08:15 PM
I have two times

12:39:30PM

and

11:41:27AM

How to get the difference between the two times given?

Vikram N
August 3rd, 2001, 08:29 AM
Convert the times into secs and then calculate the difference and then reconstruct the time

If you need more details..let me know..

Cheers
Vikram

bayard
August 3rd, 2001, 09:35 AM
You'll need to write your own code to reconstruct the time. Seems to be a missing bit in the java time formatting.

Turn your time string into a Date object using a SimpleDateFormat. Then get the seconds from that.
Work out difference.
Write some of your own code to turn the seconds into a formatted string. If you use the standard
code I believe you'll get a date, sometime early in 1970.

Bayard
bayard@generationjava.com
http://www.generationjava.com

Brainbench MVP for Java
http://www.brainbench.com