Enum TimeUtil

java.lang.Object
java.lang.Enum<TimeUtil>
org.influxdb.impl.TimeUtil
All Implemented Interfaces:
Serializable, Comparable<TimeUtil>, java.lang.constant.Constable

public enum TimeUtil
extends Enum<TimeUtil>
Utils for time related methods.
Author:
stefan.majer [at] gmail.com
  • Enum Constant Details

  • Field Details

  • Method Details

    • values

      public static TimeUtil[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static TimeUtil valueOf​(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • toTimePrecision

      public static String toTimePrecision​(TimeUnit t)
      Convert from a TimeUnit to a influxDB timeunit String.
      Parameters:
      t - the TimeUnit
      Returns:
      the String representation.
    • toInfluxDBTimeFormat

      public static String toInfluxDBTimeFormat​(long time)
      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
      Parameters:
      time - timestamp to use, in unix epoch time
      Returns:
      influxdb compatible date-tome string
    • fromInfluxDBTimeFormat

      public static long fromInfluxDBTimeFormat​(String time)
      convert an influxdb timestamp used by influxdb to unix epoch time. influxdb time format example: 2016-10-31T06:52:20.020Z or 2016-10-31T06:52:20Z
      Parameters:
      time - timestamp to use, in influxdb datetime format
      Returns:
      time in unix epoch time