Instant ofEpochSecond(long epochSecond, long nanoAdjustment) example

Description

Instant ofEpochSecond(long epochSecond, long nanoAdjustment) gets an instance of Instant using seconds from the epoch of 1970-01-01T00:00:00Z and nanosecond fraction of second.

Syntax

ofEpochSecond has the following syntax.


public static Instant ofEpochSecond(long epochSecond,   long nanoAdjustment)

Example

The following example shows how to use ofEpochSecond.


import java.time.Instant;
//w w  w.ja v a 2 s. c o  m
public class Main {
  public static void main(String[] args) {
    Instant instant = Instant.ofEpochSecond(123123123123L,123123);
    System.out.println(instant.getEpochSecond());
    
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset