Example usage for java.time Instant getEpochSecond

List of usage examples for java.time Instant getEpochSecond

Introduction

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

Prototype

public long getEpochSecond() 

Source Link

Document

Gets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z.

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:Main.java

public static void main(String[] args) {
    Instant now = Instant.now();
    System.out.println(now);/*  w  w  w. j  a v  a  2  s.com*/
    System.out.println(now.getEpochSecond());
    System.out.println(now.getNano());
}

From source file:Main.java

public static void main(String[] args) {

    // same time in millis
    Instant now = Instant.ofEpochMilli(1262347200000l);

    long toUnixTimestamp = now.getEpochSecond();

    System.out.println(toUnixTimestamp);
}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    System.out.println(instant.hashCode());
    System.out.println(instant.getEpochSecond());
}

From source file:Main.java

public static Date toDate(Instant instant) {
    BigInteger milis = BigInteger.valueOf(instant.getEpochSecond()).multiply(BigInteger.valueOf(1000));
    milis = milis.add(BigInteger.valueOf(instant.getNano()).divide(BigInteger.valueOf(1_000_000)));
    return new Date(milis.longValue());
}

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

static long[] instantToLongs(Instant instant) {
    if (instant == null)
        return null;
    return new long[] { instant.getEpochSecond(), instant.getNano() };
}

From source file:com.teradata.benchto.service.BenchmarkControllerTest.java

private static String toJsonRepresentation(Instant instant) {
    return format("%d.%03d", instant.getEpochSecond(), instant.toEpochMilli() % 1000);
}

From source file:com.twitter.heron.healthmgr.common.ComponentMetricsHelper.java

public void computeBufferSizeTrend() {
    for (InstanceMetrics instanceMetrics : componentMetrics.getMetrics().values()) {
        Map<Instant, Double> bufferMetrics = instanceMetrics.getMetrics().get(METRIC_BUFFER_SIZE.text());
        if (bufferMetrics == null || bufferMetrics.size() < 3) {
            // missing of insufficient data for creating a trend line
            continue;
        }// ww  w .  ja  v  a 2s .c  o m

        SimpleRegression simpleRegression = new SimpleRegression(true);
        for (Instant timestamp : bufferMetrics.keySet()) {
            simpleRegression.addData(timestamp.getEpochSecond(), bufferMetrics.get(timestamp));
        }

        double slope = simpleRegression.getSlope();
        instanceMetrics.addMetric(METRIC_WAIT_Q_GROWTH_RATE.text(), slope);

        if (maxBufferChangeRate < slope) {
            maxBufferChangeRate = slope;
        }
    }
}

From source file:com.create.batch.integration.FileMessageToJobRequest.java

@Transformer(inputChannel = "inboundFileChannel", outputChannel = "outboundJobRequestChannel")
public JobLaunchRequest toRequest(final Message<File> message) {
    log.debug("toRequest : {}", message);
    final Instant timestamp = clock.instant();
    final JobParameters jobParameters = new JobParametersBuilder()
            .addString(jobParameter, message.getPayload().getAbsolutePath())
            .addLong(TIMESTAMP_PARAMETER, timestamp.getEpochSecond()).toJobParameters();
    return new JobLaunchRequest(job, jobParameters);
}

From source file:org.jhk.pulsing.web.service.prod.PulseService.java

/**
 * Hmmm should work in DRPC from storm+trident to get notified of new batch and then send 
 * the message to client component for new set? Look into it since familiar only w/ trident
 * // w ww. ja v  a 2s.  c  o  m
 * @param numMinutes
 * @return
 */
@Override
public Map<Long, String> getTrendingPulseSubscriptions(int numMinutes) {

    Instant current = Instant.now();
    Instant beforeRange = current.minus(numMinutes, ChronoUnit.MINUTES);

    Optional<Set<String>> optTps = redisPulseDao.getTrendingPulseSubscriptions(beforeRange.getEpochSecond(),
            current.getEpochSecond());

    @SuppressWarnings("unchecked")
    Map<Long, String> tpSubscriptions = Collections.EMPTY_MAP;

    if (optTps.isPresent()) {
        tpSubscriptions = PulseServiceUtil.processTrendingPulseSubscribe(optTps.get(), _objectMapper);
    }
    ;

    return tpSubscriptions;
}