Java Instant.ofEpochMilli() Method with Examples

Tags: Java Instant Java 8

In this Java core tutorial we learn how to use the java.time.Instant.ofEpochMilli() static method to create a new Instant object from an epoch milliseconds value in Java programming language.

Create new Instant object from epoch milliseconds

In Java we can use the Instant.ofEpochMilli(long epochMilli) static method to instantiate a new Instant object from an epoch milliseconds value as the example Java code below.

InstantOfEpochMilliExample1.java

import java.time.Instant;

public class InstantOfEpochMilliExample1 {
    public static void main(String... args) {
        Instant instant = Instant.ofEpochMilli(999999999);

        System.out.println(instant);
    }
}
The output as below.
1970-01-12T13:46:39.999Z

Happy Coding 😊

Java Instant.now() Method with Examples

Java Instant.ofEpochSecond() Method with Examples

Java Instant.parse() Method with Examples

Java Instant.getEpochSecond() Method with Examples

Java Instant.getNano() Method with Examples

Java Instant.plusSeconds() Method with Examples

Java Instant.plusMillis() Method with Examples

Java Instant.plusNanos() Method with Examples

Java Instant.minusSeconds() Method with Examples

Java Instant.minusMillis() Method with Examples

Java Instant.minusNanos() Method with Examples

Java Instant.atOffset() Method with Examples

Java Instant.atZone() Method with Examples

Java Instant.toEpochMilli() Method with Examples

Java Instant.compareTo() Method with Examples

Java Instant.isAfter() Method with Examples

Java Instant.isBefore() Method with Examples

Java Instant.equals() Method with Examples

Java Instant.toString() Method with Examples

Java Compare two Instant Values