mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8176841: Additional Unicode Language-Tag Extensions
8189134: New system properties for the default Locale extensions 8190918: Retrieve the region specific data regardless of language in locale 8191349: Add a new method in j.t.f.DateTimeFormatter to reflect Unicode extensions Reviewed-by: scolebourne, lancea, rriggs, rgoel, nishjain
This commit is contained in:
parent
3246c46f41
commit
f065141ddc
55 changed files with 3631 additions and 890 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -79,6 +79,7 @@ import java.time.chrono.Chronology;
|
|||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import sun.util.locale.provider.CalendarDataUtility;
|
||||
import sun.util.locale.provider.LocaleProviderAdapter;
|
||||
import sun.util.locale.provider.LocaleResources;
|
||||
|
||||
|
@ -632,7 +633,9 @@ public enum ChronoField implements TemporalField {
|
|||
}
|
||||
|
||||
LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
|
||||
.getLocaleResources(locale);
|
||||
.getLocaleResources(
|
||||
CalendarDataUtility
|
||||
.findRegionOverride(locale));
|
||||
ResourceBundle rb = lr.getJavaTimeFormatData();
|
||||
String key = "field." + displayNameKey;
|
||||
return rb.containsKey(key) ? rb.getString(key) : name;
|
||||
|
|
|
@ -81,6 +81,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import sun.util.locale.provider.CalendarDataUtility;
|
||||
import sun.util.locale.provider.LocaleProviderAdapter;
|
||||
import sun.util.locale.provider.LocaleResources;
|
||||
|
||||
|
@ -430,7 +431,9 @@ public final class IsoFields {
|
|||
public String getDisplayName(Locale locale) {
|
||||
Objects.requireNonNull(locale, "locale");
|
||||
LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
|
||||
.getLocaleResources(locale);
|
||||
.getLocaleResources(
|
||||
CalendarDataUtility
|
||||
.findRegionOverride(locale));
|
||||
ResourceBundle rb = lr.getJavaTimeFormatData();
|
||||
return rb.containsKey("field.week") ? rb.getString("field.week") : toString();
|
||||
}
|
||||
|
|
|
@ -286,13 +286,17 @@ public final class WeekFields implements Serializable {
|
|||
* Obtains an instance of {@code WeekFields} appropriate for a locale.
|
||||
* <p>
|
||||
* This will look up appropriate values from the provider of localization data.
|
||||
* If the locale contains "fw" (First day of week) and/or "rg"
|
||||
* (Region Override) <a href="../../util/Locale.html#def_locale_extension">
|
||||
* Unicode extensions</a>, returned instance will reflect the values specified with
|
||||
* those extensions. If both "fw" and "rg" are specified, the value from
|
||||
* the "fw" extension supersedes the implicit one from the "rg" extension.
|
||||
*
|
||||
* @param locale the locale to use, not null
|
||||
* @return the week-definition, not null
|
||||
*/
|
||||
public static WeekFields of(Locale locale) {
|
||||
Objects.requireNonNull(locale, "locale");
|
||||
locale = new Locale(locale.getLanguage(), locale.getCountry()); // elminate variants
|
||||
|
||||
int calDow = CalendarDataUtility.retrieveFirstDayOfWeek(locale);
|
||||
DayOfWeek dow = DayOfWeek.SUNDAY.plus(calDow - 1);
|
||||
|
@ -1041,7 +1045,8 @@ public final class WeekFields implements Serializable {
|
|||
Objects.requireNonNull(locale, "locale");
|
||||
if (rangeUnit == YEARS) { // only have values for week-of-year
|
||||
LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
|
||||
.getLocaleResources(locale);
|
||||
.getLocaleResources(
|
||||
CalendarDataUtility.findRegionOverride(locale));
|
||||
ResourceBundle rb = lr.getJavaTimeFormatData();
|
||||
return rb.containsKey("field.week") ? rb.getString("field.week") : name;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue