Java Code Examples for java.text.DecimalFormat#getMaximumFractionDigits()
The following examples show how to use
java.text.DecimalFormat#getMaximumFractionDigits() .
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 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 2
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 3
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 4
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 5
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 6
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 7
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 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 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 10
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 11
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 12
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 13
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 14
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 15
Source File: MathFunctions.java From Bats with Apache License 2.0 | 5 votes |
@Override public void setup() { byte[] buf = new byte[right.end - right.start]; right.buffer.getBytes(right.start, buf, 0, right.end - right.start); inputFormat = new DecimalFormat(new String(buf)); decimalDigits = inputFormat.getMaximumFractionDigits(); }
Example 16
Source File: FormatUtil.java From jackcess with Apache License 2.0 | 5 votes |
private DecimalBDFormat(DecimalFormat df) { super(df); int maxDecDigits = df.getMaximumFractionDigits(); int mult = df.getMultiplier(); while(mult > 1) { ++maxDecDigits; mult /= 10; } _maxDecDigits = maxDecDigits; }
Example 17
Source File: MathFunctions.java From Bats with Apache License 2.0 | 5 votes |
@Override public void setup() { byte[] buf = new byte[right.end - right.start]; right.buffer.getBytes(right.start, buf, 0, right.end - right.start); inputFormat = new DecimalFormat(new String(buf)); decimalDigits = inputFormat.getMaximumFractionDigits(); }
Example 18
Source File: MathFunctions.java From Bats with Apache License 2.0 | 5 votes |
@Override public void setup() { byte[] buf = new byte[right.end - right.start]; right.buffer.getBytes(right.start, buf, 0, right.end - right.start); inputFormat = new DecimalFormat(new String(buf)); decimalDigits = inputFormat.getMaximumFractionDigits(); }
Example 19
Source File: MathFunctions.java From dremio-oss with Apache License 2.0 | 4 votes |
public void setup() { byte[] buf = new byte[right.end - right.start]; right.buffer.getBytes(right.start, buf, 0, right.end - right.start); inputFormat = new DecimalFormat(new String(buf)); decimalDigits = inputFormat.getMaximumFractionDigits(); }