leonardBang commented on code in PR #3449:
URL: https://github.com/apache/flink-cdc/pull/3449#discussion_r1704843782


##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/functions/SystemFunctionUtils.java:
##########
@@ -38,65 +41,62 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import static 
org.apache.flink.cdc.common.utils.DateTimeUtils.timestampMillisToDate;
+import static 
org.apache.flink.cdc.common.utils.DateTimeUtils.timestampMillisToTime;
+
 /** System function utils to support the call of flink cdc pipeline transform. 
*/
 public class SystemFunctionUtils {
-    private static final Logger LOG = 
LoggerFactory.getLogger(SystemFunctionUtils.class);
 
-    public static int localtime(long epochTime, String timezone) {
-        return DateTimeUtils.timestampMillisToTime(epochTime);
-    }
+    private static final Logger LOG = 
LoggerFactory.getLogger(SystemFunctionUtils.class);
 
-    public static TimestampData localtimestamp(long epochTime, String 
timezone) {
-        return TimestampData.fromMillis(epochTime);
+    public static LocalZonedTimestampData currentTimestamp(long epochTime) {
+        return LocalZonedTimestampData.fromEpochMillis(epochTime);
     }
 
-    // synonym: localtime
-    public static int currentTime(long epochTime, String timezone) {
-        return localtime(epochTime, timezone);
+    // synonym with currentTimestamp
+    public static LocalZonedTimestampData now(long epochTime) {
+        return LocalZonedTimestampData.fromEpochMillis(epochTime);
     }
 
-    public static int currentDate(long epochTime, String timezone) {
-        return DateTimeUtils.timestampMillisToDate(epochTime);
+    public static TimestampData localtimestamp(long epochTime, String 
timezone) {
+        return TimestampData.fromLocalDateTime(
+                
Instant.ofEpochMilli(epochTime).atZone(ZoneId.of(timezone)).toLocalDateTime());
     }
 
-    public static TimestampData currentTimestamp(long epochTime, String 
timezone) {
-        return TimestampData.fromMillis(
-                epochTime + 
TimeZone.getTimeZone(timezone).getOffset(epochTime));
+    public static int localtime(long epochTime, String timezone) {
+        return timestampMillisToTime(localtimestamp(epochTime, 
timezone).getMillisecond());
     }
 
-    public static LocalZonedTimestampData now(long epochTime, String timezone) 
{
-        return LocalZonedTimestampData.fromEpochMillis(epochTime);
+    public static int currentTime(long epochTime, String timezone) {
+        // the time value of currentTimestamp under given session time zone
+        return timestampMillisToTime(localtimestamp(epochTime, 
timezone).getMillisecond());
     }
 
-    public static String dateFormat(LocalZonedTimestampData timestamp, String 
format) {
-        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
-        return dateFormat.format(new Date(timestamp.getEpochMillisecond()));
+    public static int currentDate(long epochTime, String timezone) {
+        // the date value of currentTimestamp under given session time zone
+        return timestampMillisToDate(localtimestamp(epochTime, 
timezone).getMillisecond());
     }
 
     public static String dateFormat(TimestampData timestamp, String format) {
-        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
-        return dateFormat.format(new Date(timestamp.getMillisecond()));
-    }
-
-    public static String dateFormat(ZonedTimestampData timestamp, String 
format) {
-        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
-        return dateFormat.format(new Date(timestamp.getMillisecond()));
+        return DateTimeUtils.formatTimestampMillis(
+                timestamp.getMillisecond(), format, 
TimeZone.getTimeZone("UTC"));

Review Comment:
   yes, TimestampData is timezone unrelated data structure. 



-- 
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-unsubscr...@flink.apache.org

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

Reply via email to