[ https://issues.apache.org/jira/browse/FLINK-9962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16587301#comment-16587301 ]
ASF GitHub Bot commented on FLINK-9962: --------------------------------------- kl0u commented on a change in pull request #6492: [FLINK-9962] [FS connector] allow users to specify TimeZone in DateTimeBucketer URL: https://github.com/apache/flink/pull/6492#discussion_r211538279 ########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/filesystem/bucketassigners/DateTimeBucketAssigner.java ########## @@ -59,32 +60,56 @@ private static final String DEFAULT_FORMAT_STRING = "yyyy-MM-dd--HH"; private final String formatString; + private final ZoneId zoneId; - private transient SimpleDateFormat dateFormatter; + private transient DateTimeFormatter dateTimeFormatter; /** - * Creates a new {@code DateTimeBucketer} with format string {@code "yyyy-MM-dd--HH"}. + * Creates a new {@code DateTimeBucketAssigner} with format string {@code "yyyy-MM-dd--HH"}. */ public DateTimeBucketAssigner() { this(DEFAULT_FORMAT_STRING); } /** - * Creates a new {@code DateTimeBucketer} with the given date/time format string. + * Creates a new {@code DateTimeBucketAssigner} with the given date/time format string. * * @param formatString The format string that will be given to {@code SimpleDateFormat} to determine - * the bucket path. + * the bucket id. */ public DateTimeBucketAssigner(String formatString) { + this(formatString, ZoneId.systemDefault()); + } + + /** + * Creates a new {@code DateTimeBucketAssigner} with format string {@code "yyyy-MM-dd--HH"} using the given timezone. + * + * @param zoneId The timezone used to format {@code DateTimeFormatter} for bucket id. + */ + public DateTimeBucketAssigner(ZoneId zoneId) { + this(DEFAULT_FORMAT_STRING, zoneId); + } + + /** + * Creates a new {@code DateTimeBucketAssigner} with the given date/time format string using the given timezone. + * + * @param formatString The format string that will be given to {@code DateTimeFormatter} to determine + * the bucket path. + * @param zoneId The timezone used to format {@code DateTimeFormatter} for bucket id. + */ + public DateTimeBucketAssigner(String formatString, ZoneId zoneId) { this.formatString = formatString; + this.zoneId = zoneId; Review comment: Missing check for nulls: ``` this.formatString = Preconditions.checkNotNull(formatString); this.zoneId = Preconditions.checkNotNull(zoneId); ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > allow users to specify TimeZone in DateTimeBucketer > --------------------------------------------------- > > Key: FLINK-9962 > URL: https://issues.apache.org/jira/browse/FLINK-9962 > Project: Flink > Issue Type: Improvement > Components: Streaming Connectors > Affects Versions: 1.5.1, 1.6.0 > Reporter: Bowen Li > Assignee: Bowen Li > Priority: Major > Labels: pull-request-available > Fix For: 1.7.0 > > > Currently {{DateTimeBucketer}} will return a bucket path by using local > timezone. We should add a {{timezone}} constructor param to allow users to > specify a timezone. -- This message was sent by Atlassian JIRA (v7.6.3#76005)