Java Instant ofEpochMilli() method

The ofEpochMilli() method of Java Instant class is used to obtain an instance of Instant using milliseconds from the epoch of 1970-01-01T00:00:00Z The seconds and nanoseconds are extracted from the specified milliseconds.

Syntax

Parameters

epochMilli - The number of milliseconds from 1970-01-01T00:00:00Z

Return

An instant, not null.

Exceptions

DateTimeException - If the instant exceeds the maximum or minimum instant.

Example 1

Output:

The output will be like this.

1970-01-01T00:00:10Z

Example 2

Output:

The output will be like this.

123123123

Example 3

Output:

The output will be like this

2017-05-01T20:57:28.579Z