Skip to content

Commit

Permalink
Provide default values for the time fields of a date. (#1256)
Browse files Browse the repository at this point in the history
Adding defaults allows parsing a string without time information to a
date + time object.
  • Loading branch information
docbacardi authored Sep 26, 2023
1 parent a9f9cf7 commit 805631d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion engine/src/main/java/com/arcadedb/utility/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ public static Object parse(final String text, final String format) {
}

public static DateTimeFormatter getFormatter(final String format) {
return CACHED_FORMATTERS.computeIfAbsent(format, (f) -> DateTimeFormatter.ofPattern(f));
return CACHED_FORMATTERS.computeIfAbsent(format, (f) -> new DateTimeFormatterBuilder().appendPattern(f)
.parseDefaulting(ChronoField.HOUR_OF_DAY, 0)
.parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0)
.parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)
.toFormatter());
}

public static Object getDate(final Object date, final Class impl) {
Expand Down

0 comments on commit 805631d

Please sign in to comment.