< prev index next >

src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java

Print this page
rev 55871 : 8215181: Accounting currency format support
Reviewed-by:

*** 1,7 **** /* ! * Copyright (c) 1999, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1999, 2019, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 61,71 **** // Constants used by factory methods to specify a style of format. private static final int NUMBERSTYLE = 0; private static final int CURRENCYSTYLE = 1; private static final int PERCENTSTYLE = 2; ! private static final int SCIENTIFICSTYLE = 3; private static final int INTEGERSTYLE = 4; private final LocaleProviderAdapter.Type type; private final Set<String> langtags; --- 61,71 ---- // Constants used by factory methods to specify a style of format. private static final int NUMBERSTYLE = 0; private static final int CURRENCYSTYLE = 1; private static final int PERCENTSTYLE = 2; ! private static final int ACCOUNTINGSTYLE = 3; private static final int INTEGERSTYLE = 4; private final LocaleProviderAdapter.Type type; private final Set<String> langtags;
*** 182,191 **** --- 182,197 ---- LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); String[] numberPatterns = adapter.getLocaleResources(override).getNumberPatterns(); DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(override); int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE : choice; + if (choice == CURRENCYSTYLE && + numberPatterns.length > ACCOUNTINGSTYLE && + !numberPatterns[ACCOUNTINGSTYLE].isEmpty() && + "account".equalsIgnoreCase(override.getUnicodeLocaleType("cf"))) { + entry = ACCOUNTINGSTYLE; + } DecimalFormat format = new DecimalFormat(numberPatterns[entry], symbols); if (choice == INTEGERSTYLE) { format.setMaximumFractionDigits(0); format.setDecimalSeparatorAlwaysShown(false);
< prev index next >