3 ms·
Java hedges its bets. System.currentTimeMillis refers you to the docs for java.util time which states "Although the Date class is intended to reflect coordinat
by aardvark179 14y ago
Java hedges its bets. System.currentTimeMillis refers you to the docs for java.util time which states
"Although the Date class is intended to reflect coordinated universal time (UTC), it may not do so exactly, depending on the host environment of the Java Virtual Machine."
and further down in notes on possible ranges of return values
"A second is represented by an integer from 0 to 61; the values 60 and 61 occur only for leap seconds and even then only in Java implementations that actually track leap seconds correctly. Because of the manner in which leap seconds are currently introduced, it is extremely unlikely that two leap seconds will occur in the same minute, but this specification follows the date and time conventions for ISO C."
- aphyr 14y agoYeah, I was reading the same docs with confusion. My coworker cscotta dug down into the source. Oracle's JVM on Linux just calls gettimeofday(), which means System.currentTimeMillis will go all wonky during leap seconds. Ah, documentation. :D