You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "yuxiqian (via GitHub)" <gi...@apache.org> on 2025/02/28 08:22:06 UTC

Re: [PR] [FLINK-36973]udf dateformat support LocalZonedTimestampData datatype [flink-cdc]

yuxiqian commented on code in PR #3863:
URL: https://github.com/apache/flink-cdc/pull/3863#discussion_r1974998538


##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/functions/SystemFunctionUtils.java:
##########
@@ -105,6 +105,13 @@ public static String dateFormat(TimestampData timestamp, String format) {
                 timestamp.getMillisecond(), format, TimeZone.getTimeZone("UTC"));
     }
 
+    public static String dateFormat(LocalZonedTimestampData timestamp, String format) {
+        return DateTimeUtils.formatTimestampMillis(
+                timestamp.getEpochMillisecond(),
+                format,
+                TimeZone.getTimeZone(ZoneId.systemDefault()));
+    }

Review Comment:
   I believe this could be implemented by this:
   
   ### `SystemFunctionUtils` class
   
   Add an extra parameter (`timezone`) in `dateFormat` functions' signature like this:
   
   ```java
   static String dateFormat(TimestampData timestamp, String format, String timezone)
   static String dateFormat(LocalZonedTimestampData timestamp, String format, String timezone)
   ```
   
   ### `JaninoCompiler` class
   
   Move `DATE_FORMAT` from `TIMEZONE_FREE_TEMPORAL_CONVERSION_FUNCTIONS` to `TIMEZONE_REQUIRED_TEMPORAL_CONVERSION_FUNCTIONS`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org