src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
61 |
61 |
62 // Constants used by factory methods to specify a style of format. |
62 // Constants used by factory methods to specify a style of format. |
63 private static final int NUMBERSTYLE = 0; |
63 private static final int NUMBERSTYLE = 0; |
64 private static final int CURRENCYSTYLE = 1; |
64 private static final int CURRENCYSTYLE = 1; |
65 private static final int PERCENTSTYLE = 2; |
65 private static final int PERCENTSTYLE = 2; |
66 private static final int SCIENTIFICSTYLE = 3; |
66 private static final int ACCOUNTINGSTYLE = 3; |
67 private static final int INTEGERSTYLE = 4; |
67 private static final int INTEGERSTYLE = 4; |
68 |
68 |
69 private final LocaleProviderAdapter.Type type; |
69 private final LocaleProviderAdapter.Type type; |
70 private final Set<String> langtags; |
70 private final Set<String> langtags; |
71 |
71 |
182 |
182 |
183 LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); |
183 LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); |
184 String[] numberPatterns = adapter.getLocaleResources(override).getNumberPatterns(); |
184 String[] numberPatterns = adapter.getLocaleResources(override).getNumberPatterns(); |
185 DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(override); |
185 DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(override); |
186 int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE : choice; |
186 int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE : choice; |
|
187 if (choice == CURRENCYSTYLE && |
|
188 numberPatterns.length > ACCOUNTINGSTYLE && |
|
189 !numberPatterns[ACCOUNTINGSTYLE].isEmpty() && |
|
190 "account".equalsIgnoreCase(override.getUnicodeLocaleType("cf"))) { |
|
191 entry = ACCOUNTINGSTYLE; |
|
192 } |
187 DecimalFormat format = new DecimalFormat(numberPatterns[entry], symbols); |
193 DecimalFormat format = new DecimalFormat(numberPatterns[entry], symbols); |
188 |
194 |
189 if (choice == INTEGERSTYLE) { |
195 if (choice == INTEGERSTYLE) { |
190 format.setMaximumFractionDigits(0); |
196 format.setMaximumFractionDigits(0); |
191 format.setDecimalSeparatorAlwaysShown(false); |
197 format.setDecimalSeparatorAlwaysShown(false); |