Let's look into the source code of java.util.Date
:
public Date() {
this(System.currentTimeMillis());
}
So the question can be read as:
Will System.currentTimeMillis()
yield the leap second value 60 or even 61 (as the spec pretends)?
The answer is in strict sense: It depends on the underlying operating system. But fact is: All well known operating systems like Windows, Linux, Apple, Android are ignorant towards leap seconds. Instead These operating systems make any clock manipulations at any time (setting back etc., synchronizing with NTP-server...). So you will not observe a leap second using the Date
-API. By the way, the value 61 is impossible because UTC-standard mandates that UTC will never deviate from UT1 by more than 0.9 secs with the consequence that a double leap second will not be inserted.
The origin of "61" is just a gross misunderstanding from early POSIX-specifications (where this mistake has been corrected now). Unfortunately the old Java-spec has not yet been corrected causing misunderstandings until now.
About Java-8:
Yes, the so-called "Java Time-Scale" is formally specified as UTC-SLS - based on an expired proposal whose intent was rather directed towards internal implementations of NTP-servers. No implementation of UTC-SLS exist in real world. Even Java-8 does not implement UTC-SLS. Two facts prove this statement:
Java-8 does not contain a leap second table (which would be the foundation of any UTC-SLS-implementation). The Threeten-project had originally hold such one but it was removed (now also removed from the backport).
The conversion from java.util.Date
to Instant
is just 1:1 (see source code - leaving aside the different precision millis vs. nanos). Note that java.util.Date
is not mentioned in the API of Instant
with respect to the so-called "Java Time scale".
The Java time-scale is used for all date-time classes. This includes
Instant, LocalDate, LocalTime, OffsetDateTime, ZonedDateTime and
Duration.
Furthermore: The origin of java.util.Date
is from 1995 (when Java was invented) but UTC-SLS was proposed several years later.
So what is left in Java-8 as leap second support? Empty words in spec causing a lot of confusion, nothing else.
What can you do else? Within the scope of JDK simply nothing. What you need is an external 3rd-party library with built-in leap second data. An example is my library Time4J - see this article. Another option might be the library Threeten-Extra with its class UTCInstant. But I have not tested its conversion to java.util.Date
(seems to be suspect?).