I am trying to figure out how to take a String "10:23" and a String "11:30" and add the total number of minutes between these two times. ex 67 minutes These Strings are actually on JLabels Any help will be greatly appreciated
Kris Nelson
Ranch Hand
Joined: Nov 04, 2001
Posts: 35
posted
0
The way I have always done it is to create two java.util.Date objects using the different times. Using each Date object, call the object's getTime() which returns a long value of the number of milliseconds January 1, 1970, 00:00:00 GMT (a.k.a epoch). If you don't care about the dates and just worrying about the times, make the Date objects the same day. Then, simply subtract one long from the other to get the number of milliseconds between them. I think you can figure out how to convert milliseconds into hh:mm:ss etc.
------------------ WebNelly.com Java/XML Web Development Check it out! http://www.webnelly.com
WebNelly.com<br />Java/XML Web Development<br />Check it out!<br /><a href="http://www.webnelly.com" target="_blank" rel="nofollow">http://www.webnelly.com</a>
Steve Kiernan
Greenhorn
Joined: Nov 07, 2001
Posts: 6
posted
0
Originally posted by Kris Nelson: The way I have always done it is to create two java.util.Date objects using the different times. Using each Date object, call the object's getTime() which returns a long value of the number of milliseconds January 1, 1970, 00:00:00 GMT (a.k.a epoch). If you don't care about the dates and just worrying about the times, make the Date objects the same day. Then, simply subtract one long from the other to get the number of milliseconds between them. I think you can figure out how to convert milliseconds into hh:mm:ss etc.