Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 09-27-09   #1 (permalink)
New to Overclock.net
 
Join Date: Sep 2009
Posts: 2

Rep: 0 darkheart740 Unknown
Unique Rep: 0
Trader Rating: 0
Default Java Programming help?

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
darkheart740 is offline   Reply With Quote
Old 09-27-09   #2 (permalink)
PC Gamer
 
Nhb93's Avatar
 
amd nvidia

Join Date: Aug 2009
Posts: 308

Rep: 18 Nhb93 Unknown
Unique Rep: 17
Trader Rating: 0
Default

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.

System: HAFaestus (Alienware ported into HAF 932)
CPU
AMD Athlon 64 X2 6000+
Motherboard
Foxconn nForce 590 SLI
Memory
4GB
Graphics Card
GeForce 8800 GTX
Hard Drive
250GB Seagate + 750GB WD
Sound Card
Onboard
Power Supply
HIPRO HP-W700WC3 LF 700W
Case
Cooler Master HAF 932
CPU cooling
TRUE + Ceramique + San Ace 120
GPU cooling
Stock
OS
Windows 7 Professional 64-bit/Windows XP 32-bit
Monitor
Samsung SyncMaster 930B
Nhb93 is online now   Reply With Quote
Old 09-27-09   #3 (permalink)
New to Overclock.net
 
Join Date: Sep 2009
Posts: 2

Rep: 0 darkheart740 Unknown
Unique Rep: 0
Trader Rating: 0
Default

Thanks alot!!! I put it into java but it was like syntax error. could please continue? I just wish my teacher would help us and explain things but he doesn't >.>
darkheart740 is offline   Reply With Quote
Old 09-27-09   #4 (permalink)
PC Gamer
 
Nhb93's Avatar
 
amd nvidia

Join Date: Aug 2009
Posts: 308

Rep: 18 Nhb93 Unknown
Unique Rep: 17
Trader Rating: 0
Default

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.

System: HAFaestus (Alienware ported into HAF 932)
CPU
AMD Athlon 64 X2 6000+
Motherboard
Foxconn nForce 590 SLI
Memory
4GB
Graphics Card
GeForce 8800 GTX
Hard Drive
250GB Seagate + 750GB WD
Sound Card
Onboard
Power Supply
HIPRO HP-W700WC3 LF 700W
Case
Cooler Master HAF 932
CPU cooling
TRUE + Ceramique + San Ace 120
GPU cooling
Stock
OS
Windows 7 Professional 64-bit/Windows XP 32-bit
Monitor
Samsung SyncMaster 930B
Nhb93 is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 10:37 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.11287 seconds with 8 queries