ecs-logging-java icon indicating copy to clipboard operation
ecs-logging-java copied to clipboard

Add time zone support

Open felixbarny opened this issue 5 years ago • 8 comments

Use the JVM's default timezone by default and let users configure a different time zone.

felixbarny avatar Sep 27 '19 09:09 felixbarny

hope can use timezone soon.

zcranberry avatar Aug 26 '20 09:08 zcranberry

Would you be interested to implement this feature?

felixbarny avatar Aug 26 '20 10:08 felixbarny

hi, can i work on this issue?

keremh avatar Dec 08 '20 17:12 keremh

You can but in contrast to what the labels say, it's probably not a good first issue. I've tried it the other day and it's more tricky than I have though.

The reason is the requirement of not allocating objects during serialization to reduce GC pressure on the application. It means that we can't just use SimpleDataFormat or any date format that comes with the JDK. I've implemented TimestampSerializer but adding time zone support for it is quite hard. The class works under the premise that It only has to invoke SimpleDataFormat for to format the year, month and date. The result can be cached until the next day. The hour:minute:second.microsecond part of the timestamp is efficiently computed with modulo operations.

The issue is that the UTC offset can change during a day (on the day daylight savings time changes). Thus, we can't cache the UTC offset.

I don't have a good idea about how to proceed. Maybe we could use an adapted version of https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/time/FastDateFormat.html that accepts StringBuilder instead of StringBuffer. But I have not compared the performance to the current TimestampSerializer yet. So I guess that would be the first step.

felixbarny avatar Dec 08 '20 18:12 felixbarny

Thanks for your suggestion and explanations, so i look for another issue.

keremh avatar Dec 08 '20 18:12 keremh

hello, how to resolve it?

Rocky-Hu avatar Feb 05 '24 16:02 Rocky-Hu

@felixbarny

Rocky-Hu avatar Feb 05 '24 16:02 Rocky-Hu

As outlined, this is significant work, so not currently priortized

jackshirazi avatar Feb 07 '24 14:02 jackshirazi