dybyte commented on code in PR #9969:
URL: https://github.com/apache/seatunnel/pull/9969#discussion_r2447478598
##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/StringFunction.java:
##########
@@ -625,11 +631,71 @@ public static String space(List<Object> args) {
return new String(chars, StandardCharsets.ISO_8859_1);
}
+ /**
+ * Convert date/time objects to standardized string format
+ *
+ * @param obj the object to convert
+ * @return standardized string representation of the date/time object
+ */
+ private static String convertDateToString(Object obj) {
+ if (obj == null) {
+ return null;
+ }
+
+ // Handle java.util.Date and subclasses (java.sql.Date,
java.sql.Timestamp)
+ if (obj instanceof Date) {
+ Date date = (Date) obj;
+ DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ LocalDateTime localDateTime =
LocalDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC);
+ return localDateTime.format(formatter);
+ }
+
+ // Handle java.time types
+ if (obj instanceof LocalDate) {
+ LocalDate localDate = (LocalDate) obj;
+ return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
Review Comment:
Maybe we can reuse
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/DateUtils.java
here?
##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/StringFunction.java:
##########
@@ -625,11 +631,71 @@ public static String space(List<Object> args) {
return new String(chars, StandardCharsets.ISO_8859_1);
}
+ /**
+ * Convert date/time objects to standardized string format
+ *
+ * @param obj the object to convert
+ * @return standardized string representation of the date/time object
+ */
+ private static String convertDateToString(Object obj) {
+ if (obj == null) {
+ return null;
+ }
+
+ // Handle java.util.Date and subclasses (java.sql.Date,
java.sql.Timestamp)
+ if (obj instanceof Date) {
+ Date date = (Date) obj;
+ DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ LocalDateTime localDateTime =
LocalDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC);
+ return localDateTime.format(formatter);
+ }
+
+ // Handle java.time types
+ if (obj instanceof LocalDate) {
+ LocalDate localDate = (LocalDate) obj;
+ return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ }
+
+ if (obj instanceof LocalDateTime) {
+ LocalDateTime localDateTime = (LocalDateTime) obj;
+ return
localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
Review Comment:
Maybe we can reuse
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/DateTimeUtils.java
here?
--
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]