jaZon All American 27048 Posts user info edit post |
Ok, I have this simple assignment that's not so GD simple since the prof hasn't taught us anything date/time related and it's not in the book
part of the program involves the user entering a start time and finish time - how would you go about finding the difference between the two if they were given in military time?
and to keep it simple there would be no : - so it'd be 830 and 1330 for example
[Edited on October 2, 2005 at 11:49 PM. Reason : ] 10/2/2005 11:48:13 PM |
SeaCabEan All American 2298 Posts user info edit post |
perhaps i'm misunderstanding "finding the difference", but if it was military time wouldn't you just subtract 1 from the other. I would imagine you could compare to see which is bigger and then take the smaller and subtract to find the difference. Sorry if my assumptions of miltime are incorrect. 10/2/2005 11:53:37 PM |
jaZon All American 27048 Posts user info edit post |
military time still has 60 minutes in an hour 10/2/2005 11:56:22 PM |
MiniMe_877 All American 4414 Posts user info edit post |
look up the class java.lang.System in the javadocs online at http://java.sun.com
[Edited on October 2, 2005 at 11:58 PM. Reason : .]10/2/2005 11:58:02 PM |
InsaneMan All American 22802 Posts user info edit post |
http://java.sun.com/j2se/1.3/docs/api/java/util/Date.html 10/3/2005 12:12:11 AM |
jaZon All American 27048 Posts user info edit post |
yea, i'm gonna go ahead and say i'm a java n00b and none of that is helping 10/3/2005 12:21:31 AM |
DaveOT All American 11945 Posts user info edit post |
I'm reluctant to give help considering that's for a class.
But I can see a very easy way to do this that doesn't involve any special classes in Java. 10/3/2005 12:26:10 AM |
jaZon All American 27048 Posts user info edit post |
....
[Edited on October 3, 2005 at 12:27 AM. Reason : ] 10/3/2005 12:27:00 AM |
Clevelander All American 4640 Posts user info edit post |
[Edited on October 3, 2005 at 12:35 AM. Reason : crap this is for a class]
10/3/2005 12:34:23 AM |
jaZon All American 27048 Posts user info edit post |
^ lol - DaveOT gave me a good idea, though.
thanks guys 10/3/2005 12:41:39 AM |
Clevelander All American 4640 Posts user info edit post |
yeah man. I would help but I ain't trying to talk with Paul Cousins in my final semester. after Dec 15, I won't care but for now gotta cover my tail 10/3/2005 1:22:42 AM |
jaZon All American 27048 Posts user info edit post |
haha, i don't blame you - i don't want it to be just given to me either, though, but thanks
ps - i'm not at state anyway 10/3/2005 1:35:20 AM |
philihp All American 8349 Posts user info edit post |
use metric time. 10/3/2005 10:10:17 AM |
jaZon All American 27048 Posts user info edit post |
ok, so i know how i can find the difference in times one day
but....with what we've been taught i have no idea how to seperate the parts of the time....like, if the input is 0830, using the scanner class that we've been using i haven't the slightest how to split that into 08 and 30
but i think i just figured out another way - fuck the teacher
[Edited on October 3, 2005 at 2:23 PM. Reason : ] 10/3/2005 2:17:09 PM |
InsaneMan All American 22802 Posts user info edit post |
int five = "2345x6y".charAt(3) - '0'; 10/3/2005 2:24:38 PM |
jaZon All American 27048 Posts user info edit post |
done - took all of 3 minutes
i'm stupid
[Edited on October 3, 2005 at 3:47 PM. Reason : ] 10/3/2005 3:47:25 PM |
smoothcrim Universal Magnetic! 18968 Posts user info edit post |
remember how division works with int's... 2465/100 = 24 and 2465%100 = 65. I'll leave it at that. 10/3/2005 3:55:10 PM |
jaZon All American 27048 Posts user info edit post |
thanks again for the ideas guys 10/3/2005 7:59:59 PM |