Writing data to influxdb 2.7.4 using java client library 6.6.0

I encountered an issue while attempting to ingest records into InfluxDB 2.7.4 using the Java Client Library version 6.6.0. Despite using a POJO and its corresponding class for data writing, I am unable to successfully ingest records.

Specifically, I am trying to set a custom timestamp (e.g., “2023-12-13T07:20:23.021Z”) in the _time column, but for some reason, the current timestamp is being stored in the _time column when writing the data.

@Measurement(name = “temperature”)
public class Temperature {

@Column(tag = true)
String location;

@Column
Double value;

@Column(timestamp = true)
Instant time;
//getters and setters

}
And the code snippet for writing the data:

WriteApiBlocking writeApi = influxDBClient.getWriteApiBlocking();

Temperature temperature = new Temperature();
temperature.setLocation(“south”);
temperature.setValue(62D);
temperature.setTime(Instant.parse(“2023-12-13T07:20:23.021Z”));

writeApi.writeMeasurement(WritePrecision.NS, temperature);
influxDBClient.close();

I would appreciate any insights or assistance in resolving this timestamp issue. Thank you!

Hello @Vikash_Rai,
can you try using the point method?

public class InfluxDB2Example {

    private static char[] token = "my-token".toCharArray();
    private static String org = "my-org";
    private static String bucket = "my-bucket";

    public static void main(final String[] args) {

        InfluxDBClient influxDBClient = InfluxDBClientFactory.create("http://localhost:8086", token, org, bucket);

        //
        // Write data
        //
        WriteApiBlocking writeApi = influxDBClient.getWriteApiBlocking();

        //
        // Write by Data Point
        //
        Point point = Point.measurement("temperature")
                .addTag("location", "west")
                .addField("value", 55D)
                .time(Instant.now().toEpochMilli(), WritePrecision.MS);

        writeApi.writePoint(point);