Results 1 to 8 of 8
Thread: System Time
- 08-20-2009, 08:24 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 1
- Rep Power
- 0
- 08-20-2009, 08:57 PM #2
As you command: ;)
(note: i just took a wild guess as to what you are actually asking)Java Code:long startTime = System.currentTimeMillis(); int count = 0; for(int j = 0; j < Integer.MAX_VALUE; j++) count++; //spin our wheels long endTime = System.currentTimeMillis(); System.out.println("It took " + (endTime-startTime) + "ms to complete.");
-
- 08-21-2009, 04:25 AM #4
As I found out after a long and embarrassing journey, System.currentTimeMillis() may only update every 10-15 millis. That's fine if your dealing with 1/2 a second or longer, but it does add a small uncertainty for smaller periods.
- 08-21-2009, 04:41 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I agreed with you Steve.
For Java doc...
Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.
- 08-21-2009, 04:47 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I'm not sure the exact requirements here, but in designs I always try to work with avoiding the date time. It's always mess, we cannot deal with the exact time(even in milliseconds), and the best way is to deal with time stamp, or time interval. Actually that's what most of the industrial applications do. Calender make sense in Date/Time a lot.
- 08-21-2009, 06:23 AM #7
BTW, don't use System.nanoTime() if you need actual time. The "nanos" are accurate in the sense that a billion nanos are not exactly one second. They are only useful for relative comparisons.
- 08-22-2009, 02:36 PM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes, as I said earlier the most suitable way is avoid the deal with exact time as much as possible. Deal with the time interval make sense in all the way.
Similar Threads
-
setting system clocks time
By pks in forum New To JavaReplies: 4Last Post: 05-14-2009, 03:36 AM -
Class Time - represents time of day
By verbazon in forum New To JavaReplies: 1Last Post: 04-13-2009, 01:06 AM -
System time problem
By dswastik in forum CLDC and MIDPReplies: 0Last Post: 04-08-2009, 01:36 PM -
set system time
By @eddie.com in forum New To JavaReplies: 3Last Post: 09-02-2008, 03:55 PM -
Urgent-Imp-Displaying message with respect to system time
By garinapavan in forum New To JavaReplies: 1Last Post: 08-03-2007, 02:17 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks