Example usage for java.time Instant ofEpochSecond

List of usage examples for java.time Instant ofEpochSecond

Introduction

In this page you can find the example usage for java.time Instant ofEpochSecond.

Prototype

public static Instant ofEpochSecond(long epochSecond, long nanoAdjustment) 

Source Link

Document

Obtains an instance of Instant using seconds from the epoch of 1970-01-01T00:00:00Z and nanosecond fraction of second.

Usage

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.ofEpochSecond(123123123123L, 123123);
    System.out.println(instant.getEpochSecond());

}

From source file:com.aerospike.delivery.db.aerospike.AerospikeDatabase.java

static Instant longsToInstant(Record record, String binName) {
    Object value = record.getValue(binName);
    if (value == null) {
        return null;
    }/*ww w  .  java  2  s .  c om*/
    long[] parts = (long[]) value;
    return Instant.ofEpochSecond(parts[0], parts[1]);
}

From source file:org.openmhealth.shim.googlefit.mapper.GoogleFitDataPointMapper.java

/**
 * Converts a nanosecond timestamp from the Google Fit API into an offset datetime value.
 *
 * @param unixEpochNanosString the timestamp directly from the Google JSON document
 * @return an offset datetime object representing the input timestamp
 *///  w w w  . j a  v  a 2 s .com
public OffsetDateTime convertGoogleNanosToOffsetDateTime(String unixEpochNanosString) {

    return OffsetDateTime.ofInstant(Instant.ofEpochSecond(0, Long.parseLong(unixEpochNanosString)),
            ZoneId.of("Z"));
}