Flex Number Format

I want to format the number in indian format.

eg,

x = 123456 should be formatted as 1.23.456.

How can I do this in flex?

Thanks,

+4
source share
3 answers

Use the digital form.

<mx:NumberFormatter id="myFormatter" decimalSeparatorFrom="." decimalSeparatorTo="." precision="-1" rounding="none" thousandsSeparatorFrom="," thousandsSeparatorTo="," useNegativeSign="true" useThousandsSeparator="true"/> 

action code

 x = myFormatter.format(x); 
+7
source

I think that to accomplish this task you need to build your own number formatter. Just using the NumberFormatter method will only lead to the following

 123,456 and not 1,23,456 (ie the Indian style number formatting) 
+2
source

from http://livedocs.adobe.com/flex/2/langref/mx/formatters/NumberFormatter.html

Mx.formatters package Public class NumberFormatter Inheritance NumberFormatter Inheritance Formatter Inheritance Object class

The NumberFormatter class formats a valid number by setting decimal rounding and precision, thousands separator, and negative sign.

If you use both rounding and precision properties, rounding is applied first, and then you specify the decimal length using the specified precision value. This allows you to round a number and still have a finite decimal number; for example, 303.99 = 304.00.

If an error occurs, an empty string is returned and the String string describing the error is stored in the error property. The error property can have one of the following values:

  • "Invalid value" means that an invalid numeric value is passed to the format () method. The value must be a valid number in the form of a number or a string.
  • "Invalid format" means that one of the parameters contains unsuitable parameters.

MXML Syntaxcollapsed Show MXML Advanced Syntax Hide MXML Syntax

A tag inherits all the tag attributes of its superclass and adds the following tag attributes:

  <mx:NumberFormatter decimalSeparatorFrom="." decimalSeparatorTo="." precision="-1" rounding="none|up|down|nearest" thousandsSeparatorFrom="," thousandsSeparatorTo="," useNegativeSign="true|false" useThousandsSeparator="true|false"/> 
0
source

All Articles