Skip to content

@DateTimeFormat cannot accept Japanese Calendar (Wareki) [SPR-13568] #18144

@spring-projects-issues

Description

@spring-projects-issues

Toshiaki Maki opened SPR-13568 and commented

@DateTimeFormat is really useful. However Japanese Calendar (Wareki) cannot be accepted because there is no way to specify Locale to parse explicitly.

With JDK 1.6, parsing Wareki is as follows:

DateFormat format = new SimpleDateFormat("GGGGyy.MM.dd", new Locale("ja", "JP", "JP"));
format.parse("平成27.10.13"); // -> Tue Oct 13 00:00:00 JST 2015

This format is so important in Japan especially in public sectors.

org.springframework.format.datetime.DateFormatter#createDateFormat looks taking Locale object. In my understanding, the locale to be used is decided by the HTTP request and not specified by the application.
I would like to tell the locale by new attribute of @DateTimeFormat.

Supporting Date and Time API looks more difficult because the formatter needs Chronology like following:

DateTimeFormatter.ofPattern("GGGGyy.MM.dd")
                .withChronology(JapaneseChronology.INSTANCE)
                .parse("平成27.10.13"); // -> {},Japanese resolved to Japanese Heisei 27-10-13

Affects: 4.1.7, 4.2.1

Issue Links:

4 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions