influxdb-java icon indicating copy to clipboard operation
influxdb-java copied to clipboard

Reading timestamp "Cannot convert String to Long"

Open andremann opened this issue 11 years ago • 5 comments

When writing into influxDB, I provided a long as Timestamp Point.measurement(/**/).time(observation.getTimestamp(), TimeUnit.MILLISECONDS).(/**/)

However, when I read the Point back I find a formatted String 2015-07-03T09:34:25.714Z and not the long as I would expect. (Of course I get a Cast exception when trying to initialize my Pojo)

Is this wanted?

andremann avatar Jul 06 '15 13:07 andremann

Also, milliseconds are not padded 2015-07-03T09:34:27.799Z 2015-07-03T09:34:27.79Z 2015-07-03T09:34:27.8Z hence even parsing the String against the format yyyy-MM-dd'T'HH:mm:ssz with SimpleDateFormat isn't a viable solution.

andremann avatar Jul 06 '15 13:07 andremann

Hi @andremann

according to: https://influxdb.com/docs/v0.9/guides/querying_data.html

Timestamp format defaults to the format you see. It can be otoh configured with the epoch="s,ms,m,h," argument for the query. This is not yet implemented.

This can for example be implemented in a second api signature query(String query, TimeUnit unit)

Greetings Stefan

majst01 avatar Jul 06 '15 14:07 majst01

I'm also waiting for this feature as the only acceptable choice for me is timestamp long

maxboiko avatar Jul 13 '15 06:07 maxboiko

I implemented a new method query(String query, Timeunit unit) which acts as described above. This is only compile tested, so please test if this is what solves your problem.

Greetings Stefan

majst01 avatar Jul 13 '15 07:07 majst01

Worked for me, thanks

maxboiko avatar Jul 13 '15 14:07 maxboiko