|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming | |
Java Programming help?
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
New to Overclock.net
|
I need to program the time that has passed since Jan 1 1970 to the present. I know that the computer is going to put the time in milliseconds then I have to program it to Hours, minutes, Seconds. I just don't know how to program it so Help!! please. This is in Java btw
|
|
|
|
|
|
#2 (permalink) | |||||||||||||
|
PC Gamer
|
Well I'm just going to offer up the code itself, not so much the class and method headers, but I can if you need them.
int h = 0; int m = 0; int s = 0; //Figuring out how many days have passed overall since the date. int years years = 2009 - 1970; int days; days = (years * 365) + 9 //9 extra days for leap years. int days2009; days2009 = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 30 + 26; days += days2009; h = days * 24; I might be able to continue if that's what you need. If you already have the time in milliseconds, I'll give you that too right now. int h; int m; int s; h = (time in ms) / 3,600,00; m = ((time in ms) % 3,600,000) / 60; s = (((time in ms) % 3,600,000) % 60) / 60 That should work correctly. I'm an AP Computer Science student, so hopefully that works.
__________________
|
|||||||||||||
|
|
|
|
|
#4 (permalink) | |||||||||||||
|
PC Gamer
|
Well I hope you know that the regular English inside of the () was just for sake of adding onto. I'm not sure how you are pulling anything into the program per say. That would be the source of the syntax error. I'd just go into class and say something along the lines of, "I got this far, but I don't know how to finish it." He should be impressed with the code you wrote so far.
Sorry I can't be of any more help at the current time.
__________________
|
|||||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|