-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InfluxDBMapper.toPOJO() bug? #834
Comments
But this parses to the same timestamp, right |
I use |
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 is
1653354743560
, the result is2022-05-24T01:12:23.56Z
, it should be2022-05-24T01:12:23.560Z
?The text was updated successfully, but these errors were encountered: