influxdata / influxdb-java

Java client for InfluxDB
MIT License
1.18k stars 476 forks source link

Is there a way to get QueryResult like 'yyyy-MM-dd HH:mm:ss'? #698

Open arjenzhou opened 3 years ago

arjenzhou commented 3 years ago

Presently the time format of queryResult of rfc3339 is something like yyyy-MM-dd'T'HH:mm:ssX, which I excepted was yyyy-MM-dd HH:mm:ss like https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/#rfc3339-like-date-time-string.

Using SimpleDateFormat needs two-time converting

SimpleDateFormat inputSdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
SimpleDateFormat outputSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parse = inputSdf.parse(dateStr);
String format = outputSdf.format(parse);

Is there a way to get like that?

arjenzhou commented 3 years ago

In addition, how can I get result like 1.4252832E9 to be a plain number with no converting?

arjenzhou commented 3 years ago

In addition, how can I get result like 1.4252832E9 to be a plain number with no converting?

https://github.com/influxdata/influxdb-java/issues/440#issuecomment-483896165