130 * Obtains the DecimalStyle for the default
131 * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
132 * <p>
133 * This method provides access to locale sensitive decimal style symbols.
134 * <p>
135 * This is equivalent to calling
136 * {@link #of(Locale)
137 * of(Locale.getDefault(Locale.Category.FORMAT))}.
138 *
139 * @see java.util.Locale.Category#FORMAT
140 * @return the decimal style, not null
141 */
142 public static DecimalStyle ofDefaultLocale() {
143 return of(Locale.getDefault(Locale.Category.FORMAT));
144 }
145
146 /**
147 * Obtains the DecimalStyle for the specified locale.
148 * <p>
149 * This method provides access to locale sensitive decimal style symbols.
150 *
151 * @param locale the locale, not null
152 * @return the decimal style, not null
153 */
154 public static DecimalStyle of(Locale locale) {
155 Objects.requireNonNull(locale, "locale");
156 DecimalStyle info = CACHE.get(locale);
157 if (info == null) {
158 info = create(locale);
159 CACHE.putIfAbsent(locale, info);
160 info = CACHE.get(locale);
161 }
162 return info;
163 }
164
165 private static DecimalStyle create(Locale locale) {
166 DecimalFormatSymbols oldSymbols = DecimalFormatSymbols.getInstance(locale);
167 char zeroDigit = oldSymbols.getZeroDigit();
168 char positiveSign = '+';
169 char negativeSign = oldSymbols.getMinusSign();
|
130 * Obtains the DecimalStyle for the default
131 * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
132 * <p>
133 * This method provides access to locale sensitive decimal style symbols.
134 * <p>
135 * This is equivalent to calling
136 * {@link #of(Locale)
137 * of(Locale.getDefault(Locale.Category.FORMAT))}.
138 *
139 * @see java.util.Locale.Category#FORMAT
140 * @return the decimal style, not null
141 */
142 public static DecimalStyle ofDefaultLocale() {
143 return of(Locale.getDefault(Locale.Category.FORMAT));
144 }
145
146 /**
147 * Obtains the DecimalStyle for the specified locale.
148 * <p>
149 * This method provides access to locale sensitive decimal style symbols.
150 * If the locale contains "nu" (Numbering System) and/or "rg"
151 * (Region Override) <a href="../../util/Locale.html#def_locale_extension">
152 * Unicode extensions</a>, returned instance will reflect the values specified with
153 * those extensions. If both "nu" and "rg" are specified, the value from
154 * the "nu" extension supersedes the implicit one from the "rg" extension.
155 *
156 * @param locale the locale, not null
157 * @return the decimal style, not null
158 */
159 public static DecimalStyle of(Locale locale) {
160 Objects.requireNonNull(locale, "locale");
161 DecimalStyle info = CACHE.get(locale);
162 if (info == null) {
163 info = create(locale);
164 CACHE.putIfAbsent(locale, info);
165 info = CACHE.get(locale);
166 }
167 return info;
168 }
169
170 private static DecimalStyle create(Locale locale) {
171 DecimalFormatSymbols oldSymbols = DecimalFormatSymbols.getInstance(locale);
172 char zeroDigit = oldSymbols.getZeroDigit();
173 char positiveSign = '+';
174 char negativeSign = oldSymbols.getMinusSign();
|