Skip to content

Allow easy activation of ISO-by-default date and time binding for Spring MVC #20579

Closed
@odrotbohm

Description

@odrotbohm

As indicated in this ticket, it's a bit cumbersome (though doable) to make Spring MVC properly bind the ISO dates and times created through HTML input elements of type date or time. A custom WebMvcConfigurer can be used to enable this by default:

@Bean
WebMvcConfigurer isoDatesByDefault() {
  return new WebMvcConfigurer() {
    public void addFormatters(FormatterRegistry registry) {
      DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
      registrar.setUseIsoFormat(true);
      registrar.registerFormatters(registry);
    }
  }
}

As it's very likely to be what users expect to work by default, it would be cool if this could be enabled via a property. I guess for backwards compatibility reasons it should stay deactivated by default.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions