Does System.currentTimeMillis
always returns a fixed length of value. In my windows Core2, it return a 13 digit long value.
From its API:
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.
System.currentTimeMillis()
returns the number of milliseconds since epoch, i.e. since midnight UTC on the 1st January 1970.
You can check when the the number of milliseconds since epoch was 13 decimal digits for the first time. This happened on
Sep 9 2001 at 01:46:40.000 UTC (1'000'000'000'000 ms since epoch)
You can also check when the number of milliseconds since epoch is going to be 13 decimal digits for the last time. This is going to happen on
Nov 20 2286 at 17:46:39.999 UTC (9'999'999'999'999 ms since epoch)
Thus between these two dates, the function will always return 13 decimal digit value assuming the machine has the current time set correctly.
So you're safe with the assumption that the return value is 13 decimal digits for more than the next two centuries.
It returns a 63-digit binary number (it's actually a 64-bit signed number which is always positive, so the top bit is never set). Many of the leading digits will be zero. When you convert it to decimal, any leading zeroes are usually discarded. So, the number of decimal digits will vary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With