Ticket #2200 (closed defect: fixed)

Opened 2 months ago

Last modified 2 months ago

DateField formatting based on Locale is incorrect

Reported by: Jonatan Kronqvist Owned by: ticketmaster
Priority: critical Milestone: User Interface Library 5.2.12
Component: undefined Version: 5.2.11
Keywords: Cc:
Known Issue description:
Hours estimate: Deadline (dd.mm.yyyy):
Known Issue version (since): Known Issue title:
Hours done: Depends to:
Affects documentation: no
Known Issue workaround:
Affects release notes: no Contract:

Description

For example setting the locale of a datefield to fi_FI with the date 13th of December, 2008 results in the following:

13.12.2008

The same date with the locale sv_FI (note: the same country, different language) results in:

2008-12-13

They should be identical, since the date locale should follow the country and not the language.

Change History

Changed 2 months ago by Jonatan Kronqvist

Apparently DateFormat and SimpleDateFormat format the dates according to the language and not the country... This doesn't seem logical to me, but perhaps I'm not aware of some rule.

Changed 2 months ago by Jonatan Kronqvist

The problem seems to be larger than this also. For example in Denmark (Danish locale da_DK) the format returned by DateFormat follows an ISO standard producing yyyy-MM-dd, which is not in normal use in Denmark. Danes use the format dd-MM-yyyy in normal every-day use.

http://bugs.sun.com/view_bug.do?bug_id=6427322

This means that the DateField cannot currently be used by Danish software developers to provide a natural-looking date. Which makes this pretty much a blocker for any localized dates.

The addition of a setDateFormat method to the DateField component should correct this problem completely, since developers can specify the format themselves.

Changed 2 months ago by Matti Tahvonen

  • status changed from new to closed
  • resolution set to fixed

in [5862].

Jonatan, please make a code review and test that the code works well enough for your real world problems. Only tested the new feature quickly in dev environment.

Changed 2 months ago by Joonas Lehtinen

  • milestone set to User Interface Library 5.2.12

Changed 2 months ago by Jonatan Kronqvist

Works like a charm. Thank you!

Note: See TracTickets for help on using tickets.