I am trying to figure out the default java.time.LocalDateTime
format when the user pass a date in the URL as a request parameter when used in conjunction with QueryDSL
I have Looked at QuerydslPredicateArgumentResolver
, and ending with DateTimeFormatterRegistrar
and found the default to read from:
private DateTimeFormatter getFormatter(Type type) {
DateTimeFormatter formatter = this.formatters.get(type);
if (formatter != null) {
return formatter;
}
DateTimeFormatter fallbackFormatter = getFallbackFormatter(type);
return this.factories.get(type).createDateTimeFormatter(fallbackFormatter);
}
private DateTimeFormatter getFallbackFormatter(Type type) {
switch (type) {
case DATE: return DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
case TIME: return DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
default: return DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
}
}
So, the default value should be SHORT, however It seems not working as expected.
Also, how to override the format application-wide (not using the field-specific @DateTimeFormat
annotation)