Consider introducing Printer/Parser specializations of Formatter [SPR-6272] #10939
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Keith Donald opened SPR-6272 and commented
Formatter is a convenient interface to implement for parsing and printing objects. However, there could be cases where you want to register specific Printer or Parser functions for certain types for more flexibility. For example, consider Joda Time DateTimeFormatter. Such a Formatter can parse/format a Joda DateTime object, which is nice and useful. However, the Joda format library can actually print any ReadableInstant (which includes DateTime) and ReadablePartial, while only being able to parse DateTime objects. In this case, it would make logical sense to have separate ReadableInstantPrinter, ReadablePartialPrinter, and DateTimeParser classes. For the current DateTimeFormatter, ReadablePartial implementations such as LocalDate must first be coersed to DateTime before they can be printed. Having a separate Printer interface that accepted a ReadablePartial would not require such a coersion step.
Affects: 3.0 RC1
The text was updated successfully, but these errors were encountered: