Skip to content

Consider introducing Printer/Parser specializations of Formatter [SPR-6272] #10939

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions