Skip to content

Commit

Permalink
[INLONG-11372][SDK] Fix LocalTimeFunctionTest may fail in some situat…
Browse files Browse the repository at this point in the history
…ion (#11374)
  • Loading branch information
ying-hua authored Oct 21, 2024
1 parent 7cb5f15 commit 40e0d12
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
* LocalTimeFunction -> localTime([timeZoneStr])
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 40e0d12

Please sign in to comment.