The toEpochMilli() method of an Instant class is used to convert this instant to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z to a long value. This method returns that long value.
public long toEpochMilli()
Returns: This method returns number of milliseconds since the epoch of 1970-01-01T00:00:00Z.
Exception: This method throws ArithmeticException if numeric overflow occurs.
Below programs illustrate the Instant.toEpochMilli() method:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.