I am trying to send some information with Kafka. I have a class to handle this task. The class includes a private variable called "timestamp" of type Instant. When the timestamp is generated, it renders correctly. However, when I receive the message on the consumer side, the time stamp is not readable.
It looks like this "timestamp": 1685968244.889278400
Additionally, I have a response class defined as follows:
public class Response<T> {
private T data;
private String statusCode;
private String statusMessage;
private Instant timestamp;
}
When I converted timestamp
atribute to String, everything looks well but I want to render the timestamp as below:
"timestamp": 2023-06-05T15:07:06.497159Z
How can I do that ?
I suspect from Instant type. Once, I had the same problem and I fixed that when I replace Instant with DateTime from Joda-Time. Another possible solution is if you are using a custom serializer/deserializer that might occur too. So, basically, you can use JsonSerializer/JsonDeserializer. I wish this information will work for you