[
https://issues.apache.org/jira/browse/FLEX-26698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13633663#comment-13633663
]
Justin Mclean commented on FLEX-26698:
--------------------------------------
Issue still exists and interestingly enough the spark formatter also gets it
wrong (in another way).
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:a="http://flex.apache.org/ns"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
initialize="init(event)">
<fx:Script>
<![CDATA[
import flash.globalization.CurrencyFormatter;
import mx.events.FlexEvent;
import mx.formatters.CurrencyFormatter;
import spark.formatters.CurrencyFormatter;
protected function init(event:FlexEvent):void
{
var formatter1:mx.formatters.CurrencyFormatter
= new mx.formatters.CurrencyFormatter();
var value:String = formatter1.format(0);
trace("mx.formatters.CurrencyFormatter");
trace("0 = " + value);
value = formatter1.format(1);
trace("1 = " + value);
var
formatter2:spark.formatters.CurrencyFormatter = new
spark.formatters.CurrencyFormatter();
value = formatter2.format(0);
trace("spark.formatters.CurrencyFormatter");
trace("0 = " + value);
value = formatter2.format(1);
trace("1 = " + value);
var
formatter3:flash.globalization.CurrencyFormatter = new
flash.globalization.CurrencyFormatter("en_US");
value = formatter3.format(0);
trace("flash.globalization.CurrencyFormatter");
trace("0 = " + value);
value = formatter2.format(1);
trace("1 = " + value);
}
]]>
</fx:Script>
</s:Application>
Output of above:
mx.formatters.CurrencyFormatter
0 = $.0
1 = $1
spark.formatters.CurrencyFormatter
0 = 0
1 = USD1.00
flash.globalization.CurrencyFormatter
0 = 0
1 = USD1.00
Should be easy to fix if anyone wants to try.
> CurrencyFormatter returns malformed string when formatting the number 0
> -----------------------------------------------------------------------
>
> Key: FLEX-26698
> URL: https://issues.apache.org/jira/browse/FLEX-26698
> Project: Apache Flex
> Issue Type: Bug
> Components: Formatters
> Affects Versions: Adobe Flex SDK Previous
> Environment: Affected OS(s): All OS Platforms
> Affected OS(s): All OS Platforms
> Language Found: English
> Reporter: Adobe JIRA
> Labels: easyfix
>
> Steps to reproduce:
> 1. Create a CurrecyFormatter instance
> 2. Use default configuration
> 3. Attempt to format the value 0.
> Code Example:
> var formatter:CurrencyFormatter = new CurrencyFormatter();
> var value:String = formatter.format(0);
>
> Actual Results:
> value will be equal to '$.0'
>
> Expected Results:
> '$0'
>
>
> Workaround (if any):
>
> Do a secondary check for a value equal to zero in your logic prior to
> calling the formatter.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira