Skip to content

Commit

Permalink
fix: fix date function null and date handling, fixes #376 #377
Browse files Browse the repository at this point in the history
improved null value handling, added support for parsing dates
  • Loading branch information
psmf22 authored Jul 28, 2023
1 parent 5a819e4 commit 11a9c4c
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ public class StandardSpelFunctions {
private static final DateTimePeriodHelper PeriodHelper = DateTimePeriodHelper.all();

public static final OffsetDateTime date(String s) {
return OffsetDateTime.parse(s);
if(s == null) { return null; }

OffsetDateTime dt = null;
try {
dt= OffsetDateTime.parse(s);
} catch(DateTimeParseException e) {
LocalDate d = LocalDate.parse(s);
dt = OffsetDateTime.of(d.atStartOfDay(), ZoneOffset.UTC);
}

return dt;
}

public static final OffsetDateTime now(String... s) {
Expand Down

0 comments on commit 11a9c4c

Please sign in to comment.