ThreeTen / threeten

This project was the home of code used to develop a modern date and time library for JDK8. Development has moved to OpenJDK and a separate backport project, threetenbp.
http://threeten.github.io/
191 stars 37 forks source link

Lookup of ChronoDate by Locale #57

Closed RogerRiggs closed 12 years ago

RogerRiggs commented 12 years ago

The factories for ChronoDate must provide a factory to provide the appropriate calendar for the chronolog(ies) appropriate for a specified Locale. The current java.util.Calendar handles this case using the extended Locale strings.

jodastephen commented 12 years ago

Since a locale does not map 1 to 1 to a calendar system, this method seems dubious. Other APIs effectively map a locale to a list of calendar systems, which a user then picks from, potentially with a default/preferred one.

Note that there is no real disagreement here, just confusion as to how the method to find a Chronology from a Locale would actually work and whether it would really be useful. Explain that, and then it can be approved (or implement and associate a pull request)

RogerRiggs commented 12 years ago

This functionality is already present in java.util.Calendar and JSR 310 needs to provide equivalent functionality. The selection of a Locale preferred calender should not be left the application. The application does not have enough information to map locales to calendars. The suggestion you made when this was proposed earlier is to return an ordered array of potential calendars. The application can chose between them or just take the first, preferred calendar.

jodastephen commented 12 years ago

I'm happy to support a method on Chronology, something like this:

public static List getChronologies(Locale)

If the globalization team believe that a Locale can most of the time be mapped to 1 chronology, then I would also support.

public static Chronology ofLocale(Locale)

This shouldn't be in there "just" because the JDK has it now. The JDK may well be wrong (in that there isn't a 1-1 mapping).

jodastephen commented 12 years ago

I've added ofLocale(Locale) based on the implementation in Calendar, using the locale extensions. While the locale design these days is a weird cludge, it is sound enough to add this method. A list of chronologies by locale would be useful, but can be added later.

The I18N teams will need to perform a sweep of the I18N code at some point to check the assumptions made are correct.

dchiba commented 12 years ago

Hi Stephen, would you add the method to get the list? This is a 1:n mapping and can be precisely as you noted above:

public static List getChronologies(Locale)

CLDR defines the preferred calendars for each locale. This information is useful for an application to provide choices of a calendar in a user-friendly way, for instance, by limiting the choices to the preferred calendars and not others. Since this issue is closed, let me file this as a new issue, or can you revert the status to open?

jodastephen commented 12 years ago

Please open a new issue. On Sep 25, 2012 1:57 AM, "Dan Chiba" notifications@github.com wrote:

Hi Stephen, would you add the method to get the list? This is a 1:n mapping and can be precisely as you noted above:

public static List getChronologies(Locale)

CLDR defines the preferred calendars for each locale. This information is useful for an application to provide choices of a calendar in a user-friendly way, for instance, by limiting the choices to the preferred calendars and not others. Since this issue is closed, let me file this as a new issue, or can you revert the status to open?

— Reply to this email directly or view it on GitHubhttps://github.com/ThreeTen/threeten/issues/57#issuecomment-8839334.