Oracle Fusion Middleware extensions for Applications Core API Reference
11g Release 1 (11.1.2)

E22562-02

oracle.apps.fnd.applcore.i18n.text
Class NumberFormatter

java.lang.Object
  extended by oracle.apps.fnd.applcore.i18n.text.NumberFormatter

public abstract class NumberFormatter
extends java.lang.Object

NumberFormatter is an abstract class which defines the method for number formatting based on the user preferences.

The APIs should be called only the case ADF Faces number formatting function cannot be utilize.

Rounding

NumberFormatter uses half-even rounding (see java.math.BigDecimal.ROUND_HALF_EVEN) for formatting.

Synchronization

NumberFormatter and its subclasses are generally not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.

Example

 NumberFormatter formatter = NumberFormatter.getInstance(FormatUtil
   .getI18NContext(ApplSessionUtil.getSession()));
 //or
 //NumberFormatter formatter =
 //  FormatUtil.getNumberFormatterInstance(ApplSessionUtil.getSession());
 BigDecimal number = new BigDecimal("-12345.67");

 String formattedString = formatter.format(number);

 Number parsedNumber = formatter.parse(formattedString);
 


Constructor Summary
NumberFormatter()
           
 
Method Summary
abstract  java.lang.String format(java.lang.Number numericValue)
          Returns formatted string from Number value based on user preferences.
static NumberFormatter getInstance(I18NContext context)
          Returns NumberFormatter instance.
static NumberFormatter getInstance(I18NContext context, java.lang.String formatMask, java.lang.String parseMask)
          Returns NumberFormatter instance.
abstract  java.lang.Number parse(java.lang.String text)
          Returns Number object parsed from String value.
abstract  void setGroupingUsed(boolean newValue)
          Set whether or not grouping will be used in this format.
abstract  void setMaximumFractionDigits(int newValue)
          Sets the maximum number of digits allowed in the fraction portion of a number.
abstract  void setMinimumFractionDigits(int newValue)
          Sets the minimum number of digits allowed in the fraction portion of a number.
abstract  void setMultiplier(int newValue)
          Sets the multiplier for use in percent, per mille, and similar formats.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberFormatter

public NumberFormatter()
Method Detail

getInstance

public static NumberFormatter getInstance(I18NContext context)
Returns NumberFormatter instance.

Parameters:
context - I18NContext, I18N context information for the current session.
Returns:
NumberFormatter

getInstance

public static NumberFormatter getInstance(I18NContext context,
                                          java.lang.String formatMask,
                                          java.lang.String parseMask)
Returns NumberFormatter instance.

Parameters:
context - I18NContext, I18N context information for the current session.
formatMask - String, java format mask for formatting.
parseMask - String, java format mask for parsing.
Returns:
NumberFormatter

format

public abstract java.lang.String format(java.lang.Number numericValue)
Returns formatted string from Number value based on user preferences.

Parameters:
numericValue - Number, numeric value to be formatted.
Returns:
String, formatted number.

parse

public abstract java.lang.Number parse(java.lang.String text)
Returns Number object parsed from String value. If the given string cannot be parsed as a date, null is returned.

Parameters:
text - String, to be parsed.
Returns:
Number, parsed.

setMaximumFractionDigits

public abstract void setMaximumFractionDigits(int newValue)
Sets the maximum number of digits allowed in the fraction portion of a number. For formatting numbers other than BigInteger and BigDecimal objects, the lower of newValue and 340 is used. Negative input values are replaced with 0.

Parameters:
newValue - int, the maximum number of fraction digits to be shown; if less than zero, then zero is used.

setGroupingUsed

public abstract void setGroupingUsed(boolean newValue)
Set whether or not grouping will be used in this format.

Parameters:
newValue - boolean

setMinimumFractionDigits

public abstract void setMinimumFractionDigits(int newValue)
Sets the minimum number of digits allowed in the fraction portion of a number. minimumFractionDigits must be <= maximumFractionDigits. If the new value for minimumFractionDigits exceeds the current value of maximumFractionDigits, then maximumIntegerDigits will also be set to the new value

Parameters:
newValue - the minimum number of fraction digits to be shown; if less than zero, then zero is used. The concrete subclass may enforce an upper limit to this value appropriate to the numeric type being formatted.

setMultiplier

public abstract void setMultiplier(int newValue)
Sets the multiplier for use in percent, per mille, and similar formats. For a percent format, set the multiplier to 100 and the suffixes to have '%' (for Arabic, use the Arabic percent sign). For a per mille format, set the multiplier to 1000 and the suffixes to have '\u2030'.

Example: with multiplier 100, 1.23 is formatted as "123", and "123" is parsed into 1.23.


Oracle Fusion Middleware extensions for Applications Core API Reference
11g Release 1 (11.1.2)

E22562-02

Copyright © 2011 Oracle. All Rights Reserved.