Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document defaults for spring.mvc.format.* and spring.webflux.format.* properties #30041

Closed
membersound opened this issue Jul 19, 2021 · 2 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@membersound
Copy link

membersound commented Jul 19, 2021

Why are there no default settings for spring.mvc.format.* properties?

I mean: spring is convention over configuration, but when I send a POST request and want spring to parse values like 2021-07-19 into a java.time.LocalDate or java.time.LocalDateTime field, I have to explicit op-in?

Please consider setting them to some reasonable values, like:

#yyyy-MM-dd
spring.mvc.format.date=iso
spring.mvc.format.time=HH:mm:ss
spring.webflux.format.date=...
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 19, 2021
@wilkinsona
Copy link
Member

wilkinsona commented Jul 19, 2021

There are defaults but they're not expressed in the metadata at the moment. When the properties aren't configured, your app will use the fallbacks provided by Framework's DateTimeFormatterRegistrar:

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);
	}
}

Changing the defaults would be a breaking change which we generally try to avoid. It may be possible for us to improve the metadata though.

@membersound
Copy link
Author

membersound commented Jul 19, 2021

Okay, while I feel FormatStyle.SHORT is a rather bad default for date, at least it could be added to the metadata and docs for clarification? Would be nice!

@wilkinsona wilkinsona changed the title Set defaults for spring.mvc.format.* properties Document defaults for spring.mvc.format.* and spring.webflux.format.* properties Jul 20, 2021
@wilkinsona wilkinsona added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 20, 2021
@bclozel bclozel transferred this issue from spring-projects/spring-boot Mar 3, 2022
@bclozel bclozel added for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged type: documentation A documentation update and removed type: documentation A documentation update for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Mar 3, 2022
@bclozel bclozel transferred this issue from spring-projects/spring-framework Mar 3, 2022
@wilkinsona wilkinsona added this to the 2.5.x milestone Mar 3, 2022
@wilkinsona wilkinsona modified the milestones: 2.5.x, 2.6.x May 19, 2022
@wilkinsona wilkinsona modified the milestones: 2.6.x, 2.7.x Nov 24, 2022
@wilkinsona wilkinsona self-assigned this Aug 8, 2023
@wilkinsona wilkinsona modified the milestones: 2.7.x, 2.7.15 Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

4 participants