Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
Accepted Solution

NumberFormatter Bug?

has anyone else experienced the following bug with NumberFormatter on the simulator?

 

var numFormat:NumberFormatter = new NumberFormatter(LocaleID.DEFAULT);
numFormat.leadingZero = true;
numFormat.trailingZeros = true;
numFormat.fractionalDigits = 2;

myTextField.text = numFormat.formatNumber(2050));

 the above code should return the following string value:

 

2,050.00

but it's not including the groupingSeperator (the comma) and returns this instead:

 

2050.00

 

 

 

 

 


PlayBook Applications:
Drop Swatch
Developer
Posts: 119
Registered: ‎03-10-2010
My Device: Bold 9000

Re: NumberFormatter Bug?

Hi,

 

Did you try actually setting the groupingSeparator ? Or even use "EN_us" for example? 

 

Just to see if it changes the behavior?

 

Cheers

 

 



(*) Kudo-me if you really think I helped you!
My plug: I'm doing a Mobile Experiment, reported on my Blog: Check it out!.
---------------------------
Paulo Garcia
http://www.mobilecreators.com - Twitter: http://twitter.com/mobilecreators
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: NumberFormatter Bug?

hey darkin,

 

try setting the useGrouping property to true and see if that clears it up. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 152
Registered: ‎08-25-2010
My Device: 9530, 9550, 9630

Re: NumberFormatter Bug?

[ Edited ]

EDIT:// Just noticed the "NumberFormatter"

<mx:CurrencyFormatter id="Price" precision="2"
rounding="none"
decimalSeparatorTo="."
thousandsSeparatorTo=","
useThousandsSeparator="true"
useNegativeSign="true"
currencySymbol="$"
alignSymbol="left"/>

 

theres what i use, assuming youre doing currency

 

Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook

Re: NumberFormatter Bug?

[ Edited ]

 


JRab wrote:

hey darkin,

 

try setting the useGrouping property to true and see if that clears it up. good luck!


 

setting useGrouping property to true didn't have any effect unfortunately.

 

 

 

it is going to be so nice when we can finally start doing on-device debugging.

 

package
{
	//Imports
	import flash.display.Sprite;
	import flash.globalization.NumberFormatter;
	import flash.globalization.LocaleID;

	//Class
	public class PlayBookTest extends Sprite
	{	
		//Constructor
		public function PlayBookTest()
		{
			var numFormat:NumberFormatter = new NumberFormatter("EN_us");
			//var numFormat:NumberFormatter = new NumberFormatter(LocaleID.DEFAULT);
			numFormat.leadingZero = true;
			numFormat.trailingZeros = true;
			numFormat.fractionalDigits = 2;
			numFormat.useGrouping = true;
			
			trace(numFormat.formatNumber(2050));
		}
	}
}

 

 

 


PlayBook Applications:
Drop Swatch
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: NumberFormatter Bug?

Does it work in AIR without "en_US"?  If so, then I would report that as an issue with BB because the OS should assist in locality display.  Otherwise, you will have to provide your own preference to this.

 

OT: is it me or is the forum unusually busy this morning?

 

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: NumberFormatter Bug?

OT: @jtegen: not just you, noticed it too lol. almost like something "big" is coming like right before a storm. but chances are its the last day before the weekend and people are getting in before that. (yes friday is totally a weekend in my book !)

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook

Re: NumberFormatter Bug?

[ Edited ]

 


jtegen wrote:

Does it work in AIR without "en_US"?  If so, then I would report that as an issue with BB because the OS should assist in locality display.  Otherwise, you will have to provide your own preference to this.

 

OT: is it me or is the forum unusually busy this morning?

 


yup, it's works perefectly fine in ADL by simply passing LocaleID.DEFAULT as the NumberFormatter's parameter.  i also believe that useGrouping property is true by default, although it doesn't say so in the docs, and ADL displays grouping with that property set to true or by simply ignoring it.

 


PlayBook Applications:
Drop Swatch
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: NumberFormatter Bug?

I wouldn't call this a "bug" yet, but simply an unimplemented feature.

 

The device will probably have in the Settings pages a place to specify the local, language, etc.

 

For now, looking at /pps/services/confstr/_CS_LOCALE, I can see it's empty... 

 

(And it's not you... activity has jumped.  Maybe everyone who was waiting for the iPad 2 news and saw how boring it turned out, has realized there's no reason not to jump on board PlayBook development now. :-) )


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 119
Registered: ‎03-10-2010
My Device: Bold 9000

Re: NumberFormatter Bug?

Yes, 

 

my guess is that the simulator is just ignoring the LocaleId.DEFAULT thing for now... Since we can only guess here for now, I'd say you're good using it.

 

Cheers 



(*) Kudo-me if you really think I helped you!
My plug: I'm doing a Mobile Experiment, reported on my Blog: Check it out!.
---------------------------
Paulo Garcia
http://www.mobilecreators.com - Twitter: http://twitter.com/mobilecreators