搜尋部落格文章

2013年8月1日 星期四

CurrencyFormatter 貨幣地區設定格式化


package {
  import com.actionscriptbible.Example;
  import flash.globalization.*;
  public class ch41ex4 extends Example {
    public function ch41ex4() {
      var local:CurrencyFormatter = new CurrencyFormatter(LocaleID.DEFAULT);
      trace(local.format(123456.78)); //USD123,456.78
      var usa:CurrencyFormatter = new CurrencyFormatter("en-US");
      trace(usa.format(123456.78, true)); //$123,456.78
      var jp:CurrencyFormatter = new CurrencyFormatter("ja-JP");
      trace(jp.format(123456.78, true)); //¥123,457
      var de:CurrencyFormatter = new CurrencyFormatter("de-DE");
      trace (de.format(123456.78, true)); //123.456,78 €
      var fr:CurrencyFormatter = new CurrencyFormatter("fr-FR");
      trace (fr.format(123456.78, true)); //123 456,78 €
      
      var localeID:LocaleID = new LocaleID(local.actualLocaleIDName);
      trace("Local currency in " + localeID.getRegion() + ": " +
        local.currencyISOCode + " (" + local.currencySymbol + ")");
    }
  }
}

沒有留言:

張貼留言