Package org.influxdb.impl
Enum 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
-
Nested Class Summary
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
-
Field Summary
Fields Modifier and Type Field Description static int
TIME_IN_SECOND_LENGTH
-
Method Summary
Modifier and Type Method Description static long
fromInfluxDBTimeFormat(String time)
convert an influxdb timestamp used by influxdb to unix epoch time.static String
toInfluxDBTimeFormat(long time)
convert a unix epoch time to timestamp used by influxdb.static String
toTimePrecision(TimeUnit t)
Convert from a TimeUnit to a influxDB timeunit String.static TimeUtil
valueOf(String name)
Returns the enum constant of this type with the specified name.static TimeUtil[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
Field Details
-
TIME_IN_SECOND_LENGTH
public static final int TIME_IN_SECOND_LENGTH- See Also:
- Constant Field Values
-
-
Method Details
-
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
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 nameNullPointerException
- if the argument is null
-
toTimePrecision
Convert from a TimeUnit to a influxDB timeunit String.- Parameters:
t
- the TimeUnit- Returns:
- the String representation.
-
toInfluxDBTimeFormat
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
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
-