From 40e0d1262b2533c77cab600318a8565f2a473728 Mon Sep 17 00:00:00 2001 From: Xincheng Huang <60057611+ying-hua@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:09:23 +0800 Subject: [PATCH] [INLONG-11372][SDK] Fix LocalTimeFunctionTest may fail in some situation (#11374) --- .../process/function/temporal/LocalTimeFunction.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/temporal/LocalTimeFunction.java b/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/temporal/LocalTimeFunction.java index 0a998a7a48..dd79a64cb3 100644 --- a/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/temporal/LocalTimeFunction.java +++ b/inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/temporal/LocalTimeFunction.java @@ -28,6 +28,7 @@ import java.time.LocalTime; import java.time.ZoneId; +import java.time.format.DateTimeFormatter; /** * LocalTimeFunction -> localTime([timeZoneStr]) @@ -55,11 +56,12 @@ public LocalTimeFunction(Function expr) { @Override public Object parse(SourceData sourceData, int rowIndex, Context context) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); if (stringParser != null) { String zoneString = OperatorTools.parseString(stringParser.parse(sourceData, rowIndex, context)); - return LocalTime.now(ZoneId.of(zoneString)).withNano(0); + return LocalTime.now(ZoneId.of(zoneString)).withNano(0).format(formatter); } else { - return LocalTime.now(ZoneId.systemDefault()).withNano(0); + return LocalTime.now(ZoneId.systemDefault()).withNano(0).format(formatter); } } }