[ 
https://issues.apache.org/jira/browse/KAFKA-7911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16858452#comment-16858452
 ] 

Mehmet Salgar commented on KAFKA-7911:
--------------------------------------

Hi,

 

I have the same problem in my Project and I tried to solving following way and 
I like to ask , is this acceptable or it is too naive...

I modified the following Java Class....

 

org\apache\kafka\streams\kstream\TimeWindows.java

 

@Override
public Map<Long, TimeWindow> windowsFor(final long timestamp) {
 TimeZone tz = TimeZone.getDefault();
 int offset = tz.getOffset(System.currentTimeMillis());
 long windowStart = (( Math.max(0, offset + timestamp - sizeMs + advanceMs) / 
advanceMs) * advanceMs) - offset;
 final Map<Long, TimeWindow> windows = new LinkedHashMap<>();
 while (windowStart <= timestamp) {
 final TimeWindow window = new TimeWindow(windowStart, windowStart + sizeMs);
 windows.put(windowStart, window);
 windowStart += advanceMs;
 }
 return windows;
}

 

 

This part 

 

TimeZone tz = TimeZone.getDefault();
int offset = tz.getOffset(System.currentTimeMillis());
long windowStart = (( Math.max(0, offset + timestamp - sizeMs + advanceMs) / 
advanceMs) * advanceMs) - offset;

 

calculate the local time zone, calculates the offset, then adds to timestamp to 
be able to find number of days from epoch start then substract it to be able to 
find "00:00" hour...

 

What do you think?

> Add Timezone Support for Windowed Aggregations
> ----------------------------------------------
>
>                 Key: KAFKA-7911
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7911
>             Project: Kafka
>          Issue Type: New Feature
>          Components: streams
>            Reporter: Matthias J. Sax
>            Priority: Minor
>              Labels: needs-kip
>
> Currently, Kafka Streams only support UTC timestamps. The impact is, that 
> `TimeWindows` are based on UTC time only. This is problematic for 24h 
> windows, because windows are build aligned to UTC-days, but not your local 
> time zone.
> While it's possible to "shift" timestamps as a workaround, it would be better 
> to allow native timezone support.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to