I have a java application that send measurements to an influxDB database.
I am adding points within my influxdb database. The points that I add each time that my program run have the current timestamp.
This is how I am adding my points (measurement building) :
BatchPoints batchPoints;
Date date = new Date();
String beginofday = Constant.simpledateFormat.format(date);
date = Constant.simpledateFormat.parse(beginofday);
long timestamp = date.getTime();
//adding points
for buildings ... do
Point point = Point.measurement("building").tag(tagsToAdd).fields(fieldsToAdd)
.time(timestamp, TimeUnit.NANOSECONDS).build();
batchPoints.point(point);
My probem is that when I am requesting my database with such a request:
select count(tag) from building where time > (my timestamp)
I noticed that previous timestamp results are also counted, even that I am doing time>timestamp. And when I do a > instead of >= it counts only last ones. I noticed also that for the just previous timestamp, for example if I have timestamp like this 1540300800000 ns, influxdb add a 6 at the begining and it becomes 61540300800000 ms.
I really don't understand what is happening.
Any ideas?
SimpleDateFormatandDate. Those classes are poorly designed and long outdated, the former in particular notoriously troublesome. Instead useInstantand other classes from java.time, the modern Java date and time API. - Ole V.V.