lhotari commented on issue #21891:
URL: https://github.com/apache/pulsar/issues/21891#issuecomment-1891380027
> ```
> MessageId messageId =
producer.newMessage().value("hello".getBytes()).send();
> ```
When using the Java API, there is no time zone information in the
`publishTime` field.
https://github.com/apache/pulsar/blob/45037399febdcf7208d8cd88bfd75bd2b1074f07/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L584
>
> By the way, the key point is the different timezones and the process of
date formatting rather than the way of producing message.
How did you determine this?
I tested formatting with a different timezone and parsing with the default
time zone (that DateFormatter.parse uses) and couldn't reproduce an issue in
the date parsing.
```java
package org.apache.pulsar.common.util;
import static org.testng.Assert.assertEquals;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import org.testng.annotations.Test;
public class DateFormatterTest {
@Test
public void differentTimeZoneShouldNotMatterInFormattingAndParsing() {
Instant now = Instant.now();
String formatted = DateTimeFormatter.ISO_OFFSET_DATE_TIME
.withZone(ZoneId.of("America/Los_Angeles")).format(now);
System.out.println(formatted);
assertEquals(now.toEpochMilli(), DateFormatter.parse(formatted));
}
}
```
That's why I think that the root cause could be different. Having full steps
and examples of timezones used in different sides (client/broker) could be
helpful in reproducing the issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]