ruanwenjun commented on code in PR #5462:
URL: https://github.com/apache/seatunnel/pull/5462#discussion_r1325406792


##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/DateTimeFunction.java:
##########
@@ -541,4 +543,16 @@ public static Integer year(List<Object> args) {
         LocalDate localDate = convertToLocalDate(datetime);
         return localDate.getYear();
     }
+
+    public static String fromUnixTime(List<Object> args) {
+        Long unixTime = (Long) args.get(0);
+        if (unixTime == null) {
+            return null;
+        }
+        String format = (String) args.get(1);
+        DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
+        LocalDateTime datetime =
+                
Instant.ofEpochSecond(unixTime).atZone(ZoneId.systemDefault()).toLocalDateTime();
+        return df.format(datetime);
+    }

Review Comment:
   It's better to add a timezone parameter.
   ```
   FROM_UNIXTIME(timestamp, format); // use default zone
   FROM_UNIXTIME(timestamp, format, timezone); // use given timezone
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to