Open trdmm opened 2 years ago
But this parses to the same timestamp, right
But this parses to the same timestamp, right
I use TimeUtil.fromInfluxDBTimeFormat(2022-05-24T01:12:23.56Z)
, the result is 1653354743056
:cry:
Can you write a Unit test which demonstrates this BUG please
Can you write a Unit test which demonstrates this BUG please
OutGzjLocation:
@Data
public class OutGzjLocation {
@TimeColumn
@Column(name = "time")
private String time;
/** imgID */
@Column(name = "imgId")
private int imgId = -1;
}
OutGzjLocationAnother:
@TimeColumn
@Column(name = "time")
private Instant time;
/** imgID */
@Column(name = "imgId")
private int imgId = -1;
SelectQueryImpl query = select().from(ConstantInfluxdb.targetDatabase, "\"10602ef9\"");
QueryResult queryResult = targetInfluxDB.query(query);
// time type is String
List<OutGzjLocation> outGzjLocations = targetInfluxDBMapper.toPOJO(queryResult, OutGzjLocation.class, "10602ef9");
// time type is Instant
List<OutGzjLocationAnother> outGzjLocationAnothers = targetInfluxDBMapper.toPOJO(queryResult, OutGzjLocationAnother.class, "10602ef9");
log.info("======time type is String======");
outGzjLocations.forEach(outGzjLocation -> {
int imgId = outGzjLocation.getImgId();
String timeStr = outGzjLocation.getTime();
if (imgId == 14 || imgId == 15){
long timestamp = TimeUtil.fromInfluxDBTimeFormat(timeStr);
log.info("Time str: {}, timestamp: {}, imgId: {}.", timeStr, timestamp,imgId);
}
});
log.info("======time type is Instant======");
outGzjLocationAnothers.forEach(outGzjLocationAnother -> {
Instant instant = outGzjLocationAnother.getTime();
int imgId = outGzjLocationAnother.getImgId();
if (imgId == 14 || imgId == 15){
log.info("Time str: {}, timestamp: {}, imgId: {}.", instant.toString(), instant.toEpochMilli(),imgId);
}
});
The result is:
======time type is String======
Time str: 2022-05-23T12:08:20.56Z, timestamp: 1653307700056, imgId: 14.
Time str: 2022-05-23T12:08:22.56Z, timestamp: 1653307702056, imgId: 15.
======time type is Instant======
Time str: 2022-05-23T12:08:20.560Z, timestamp: 1653307700560, imgId: 14.
Time str: 2022-05-23T12:08:22.560Z, timestamp: 1653307702560, imgId: 15.
Hi, nice, i mean as a Pull Request referring this Issue
When call
InfluxDBMapper.toPOJO()
, if the time field type is String and the millisecond value is an integer multiple of ten, it miss the last zero. Such as: If the timestamp is1653354743560
, the result is2022-05-24T01:12:23.56Z
, it should be2022-05-24T01:12:23.560Z
?