![]() |
for skool they got me making a telephone witch is done and now my teacher added a phone bill to it...hes having us save the info of the number dialed time/date and duration of the call.
now im using the getTime() method witch returns the time in milliseconds since 1970 to now. well i get both my longs witch are timeStart and timeEnd both get assigned a value as calls are made. now i need to find the diferende of the 2 and store it in timeDuration witch is also a long. my problem is that when i do this line. :
durationTime = (timeEnd - timeStart);thats all the code ull need to give me a hand cause all else works as it should just not that equation. BTW im Sys.out.printing them to see the values thats how i kno they are incorrect. any insite would be appreciated.TX |
Can we see the rest of the code?
|
If all of your values are indeed longs, then you should not be having a problem subtracting the two values.
:
import java.util.*;:
jowings-pb:~/devel/java jowings$ java timetest |
pay careful attention to Sykkn's example.
note that he is creating a new Date instance each time he wants to get the curent time... ie he is NOT doing: :
Date date = new Date();which was my initial thought about what you might be doing, but if you are getting the end time instead of zero then perhaps you aren't. but yeah - just look at that correct example and you might see where you went wrong. oh - and if you don't know where you are going wrong with something - don't assume that all people with need to see is a single line of your code - one which clearly has nothing wrong with it :P |
| All times are GMT -5. The time now is 1:29 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC