Support fallback parsing patterns in @DateTimeFormat
See original GitHub issuemember sound opened SPR-15736 and commented
It would be nice if one could set multiple formats for:
@DateTimeFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyyMMdd")
@DateTimeFormat(pattern = "yyyy.MM.dd")
private LocalDate date;
https://docs.oracle.com/javase/tutorial/java/annotations/repeating.html
No further details from SPR-15736
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
java.time DateTimeFormatter parsing with flexible fallback ...
Imagine I want to parse the dateformat dd/MM , then I would need to add parseDefaulting(ChronoField.YEAR, 1984) to my formatter, knowing this ...
Read more >DateTimeFormat (Spring Framework 6.0.2 API)
Fallback patterns are only used for parsing. They are not used for printing the value as a String. The primary pattern() , iso()...
Read more >Intl.DateTimeFormat - JavaScript - MDN Web Docs
Chrome Edge
DateTimeFormat Full support. Chrome24. Toggle history Full support. Edge12...
DateTimeFormat() constructor Full support. Chrome24. Toggle history Full support. Edge12...
locales parameter Full support. Chrome24....
Read more >Formatting Dates and Times | ICU Documentation
Use a DateFormat to parse also: UErrorCode status = ZERO_ERROR; UDate myDate = df ...
Read more >DateTimeFormat (GWT Javadoc)
When parsing a date string using the abbreviated year pattern ( "yy" ), the parser must interpret the abbreviated year relative to some...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Current work on this can be viewed in my feature branch: https://github.com/spring-projects/spring-framework/compare/master...sbrannen:issues/gh-20292-DateTimeFormat-patterns
The current approach is to introduce a new
String[] fallbackPatterns()
attribute that allows the user to specify a primary pattern for printing and parsing (via the existingstyle
,iso
, andpattern
attributes) with multiple fallback patterns for parsing if the primary parsing pattern fails.An example taken from the test suite:
That’s really a great idea. Well done!