The Date.getTime() and getcurrenttimemillis methods return time in milliseconds.Can anybody please explain what times these values represent? Is it system time or user time or CPU(system+user) time??
Also the
Java documentation for the getcurrenttimemillis indicates that although the method returns time in ms, the actual granularity is dependent on the Operating system. The finest possible
unit in which the time can be measured is said to be the granularity.
Are these the best possible ways to calculate the time spent on an application in Java? Or is there a way that we can get the granularity of the OS that we are working on and compensate for any differences that might arise in calculating the time??
Javadoc for the getcurrenttimemillis says the following
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.