|
| |||||||||
| Tags: date, interval, javautil, programming language, time, tools, utilities |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Retrieving interval of time
Hello, I want to recover the amount of time doing in a particular program. So I use this: Code: long tm = (new GregorianCalendar()).getTimeInMillis(); treatment (); tm = (new GregorianCalendar()).getTimeInMillis() - Time; |
|
#2
| |||
| |||
| Re: Retrieving interval of time
Hello, You can try the following code: Code: long str = System.currentTimeInMillis();
treatment ();
System.out.System.out.println("Running Time:+(System.currentTimeInMillis()-str)); |
|
#3
| |||
| |||
| Re: Retrieving interval of time
Hello, Check out the following code Code: / / Get current time
long str = System.currentTimeMillis();
/ / Do something ...
/ / Get time elapsed in milliseconds
long elapsedTimeMillis = System.currentTimeMillis()-str;
/ / Get elapsed time in seconds
float sts = elapsedTimeMillis/1000F;
/ / Get elapsed time in minutes
float elapsedTimeMin = elapsedTimeMillis /(60* 1000F);
/ / Get elapsed time in hours
float eth = elapsedTimeMillis /(60*60* 1000F);
/ / Get elapsed time in days
float etd = elapsedTimeMillis /(24*60*60* 1000F); |
|
#4
| |||
| |||
| Re: Retrieving interval of time
Hello, Why use GreporianCalendar is something quite compet me hungry and therefore memory, the simple class java.util.Date faisq quite the case: Code: long tm = (new Date()).getTime(); treatment (); tm = (new Date()).getTime() - Time; |
|
#5
| |||
| |||
| Re: Retrieving interval of time
Hello, I would like to the above post, of course, you want to have a processing time to the millionth of a second. In any case, the measure of processing time is useful for treatment rather expensive so a difference of a few thousandths of a second is negligible. If you need any more help regarding this topic then please do post back and do not forget to post your error with the code. |
|
#6
| |||
| |||
| Re: Retrieving interval of time
Hello, Thanks for you reply. It works great so the problem is RESOLVED. So thank you again (mostly for speed) The exact name of the method is: Code: long Time = System.currentTimeMillis(); Code: System.currentTimeInMillis () |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Retrieving interval of time" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unable to finish the quest because Age of empires online disconnect at regular interval of time | Leslie f | Video Games | 6 | 20-08-2011 01:11 AM |
| Airtel broadband connection keeps on getting disconnected at regular interval of time? | Ashley Parker | Technology & Internet | 7 | 30-07-2011 01:24 AM |
| LG optimus 2x smart phone get stucked at regular interval of time? | Bontu | Portable Devices | 4 | 07-07-2011 04:45 AM |
| How to modify time interval in movie maker of Windows XP | Urvaksh | Windows Software | 4 | 04-01-2011 08:27 PM |
| Problem in retrieving timestamp | Logan 2 | Software Development | 5 | 12-02-2010 01:55 AM |