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 07-06-08   #1 (permalink)
Programmer
 
LyokoHaCk's Avatar
 
amd nvidia

Join Date: Aug 2006
Location: United States Inc.
Posts: 1,995

Rep: 74 LyokoHaCk is acknowledged by some
Unique Rep: 69
FAQs Submitted: 1
Trader Rating: 2
Default Java Timestamp Help

The language I'm using in is Java.

I would like to get how many minutes have passed since a timestamp was saved (in a rounded integer preferrably). Assume I already have the timestamp saved.

Thanks!

Last edited by LyokoHaCk : 07-06-08 at 06:33 PM.
LyokoHaCk is offline   Reply With Quote
Old 07-06-08   #2 (permalink)
Apple Doesn't Love You
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 4,952
Blog Entries: 1

Rep: 560 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 335
FAQs Submitted: 6
Trader Rating: 5
Default

Assume start is the value returned from a previous call to System.currentTimeMillis()

Code:
public int minutesElapsed(long start){
 long diff = System.currentTimeMillis() - start;
 return (int)((diff)/(1000*60));
}
That will truncate rather than round. I would suggest using a double to keep the fractional portion.

Note that if you multiply by .001 before storing you lose the decimal places and are left with seconds rather than milliseconds
__________________
BIG BROTHER
I put on my robe and wizard hat...

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw

Last edited by rabidgnome229 : 07-06-08 at 12:27 AM.
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 07-06-08   #3 (permalink)
Programmer
 
LyokoHaCk's Avatar
 
amd nvidia

Join Date: Aug 2006
Location: United States Inc.
Posts: 1,995

Rep: 74 LyokoHaCk is acknowledged by some
Unique Rep: 69
FAQs Submitted: 1
Trader Rating: 2
Default

Thanks a bunch once again! I'm not going to do the conversion since it looks like I'm not using UNIX timestamp. See you later
LyokoHaCk is offline   Reply With Quote
Reply



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



All times are GMT -4. The time now is 10:18 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.13335 seconds with 9 queries