Java Code Examples for java.text.DecimalFormatSymbols#getCurrency()
The following examples show how to use
java.text.DecimalFormatSymbols#getCurrency() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberFormatProviderImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 2
Source File: NumberFormatProviderImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 3
Source File: NumberFormatProviderImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 4
Source File: NumberFormatProviderImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 5
Source File: NumberFormatProviderImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 6
Source File: NumberFormatProviderImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 7
Source File: NumberFormatProviderImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 8
Source File: NumberFormatProviderImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 9
Source File: NumberFormatProviderImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 10
Source File: NumberFormatProviderImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 11
Source File: NumberFormatProviderImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 12
Source File: NumberFormatProviderImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 13
Source File: NumberFormatProviderImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 14
Source File: NumberFormatProviderImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ private static void adjustForCurrencyDefaultFractionDigits( DecimalFormat format, DecimalFormatSymbols symbols) { Currency currency = symbols.getCurrency(); if (currency == null) { try { currency = Currency.getInstance(symbols.getInternationalCurrencySymbol()); } catch (IllegalArgumentException e) { } } if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { int oldMinDigits = format.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. if (oldMinDigits == format.getMaximumFractionDigits()) { format.setMinimumFractionDigits(digits); format.setMaximumFractionDigits(digits); } else { format.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); format.setMaximumFractionDigits(digits); } } } }
Example 15
Source File: DecimalFormatSymbolsTest.java From j2objc with Apache License 2.0 | 6 votes |
public void test_serialization() throws Exception { DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRANCE); Currency currency = symbols.getCurrency(); assertNotNull(currency); // serialize ByteArrayOutputStream byteOStream = new ByteArrayOutputStream(); ObjectOutputStream objectOStream = new ObjectOutputStream(byteOStream); objectOStream.writeObject(symbols); // and deserialize ObjectInputStream objectIStream = new ObjectInputStream( new ByteArrayInputStream(byteOStream.toByteArray())); DecimalFormatSymbols symbolsD = (DecimalFormatSymbols) objectIStream .readObject(); // The associated currency will not persist currency = symbolsD.getCurrency(); assertNotNull(currency); }