Here you can find the source of toInfluxDBTimeFormat(final Instant time)
Parameter | Description |
---|---|
time | timestamp to use, in unix epoch time |
public static String toInfluxDBTimeFormat(final Instant time)
//package com.java2s; //License from project: Open Source License import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Main { /**//from ww w . ja v a 2s . c o m * convert a unix epoch time to timestamp used by influxdb. * this can then be used in query expressions against influxdb's time column like so: * influxDB.query(new Query("SELECT * FROM some_measurement WHERE time >= '" * + toInfluxDBTimeFormat(timeStart) + "'", some_database)) * influxdb time format example: 2016-10-31T06:52:20.020Z * * @param time timestamp to use, in unix epoch time * @return influxdb compatible date-tome string */ public static String toInfluxDBTimeFormat(final Instant time) { return DateTimeFormatter.ISO_INSTANT.format(ZonedDateTime.ofInstant(time, ZoneId.of("UTC").normalized())); } }