Spec-Zone.ru › ColdFusion

lsNumberFormat

Formats a number in a locale-specific format.[mask - quicky] _,9 Digit placeholder; . decimal point; 0 Pads with zeros; ( ) less than zero, puts parentheses around the mask+ plus sign before positive number minus before negative- a space before positive minus sign before negative, Separates every third decimal place with a comma.L,C Left-justifies or center-justifies number$ dollar sign before formatted number.^ Separates left and right formatting.

lsNumberFormat(number [, mask, locale]) → returns string

  • CF
  • Lucee
  • BL 1.0.0+
  • See Also: numberFormat decimalFormat

    Argument Reference

    number numeric
    Required

    mask string
    Default: _

    locale string

    Geographic/language locale value, where the format is a combination of an ISO 639-1 code and an optional ISO 3166-1 code separated by a dash or an underscore.
    Values:
    • en
    • de_DE
    • de_CH
    • ...

    Examples
    Sample code invoking the lsNumberFormat function

    Tag Example

    lsNumberFormat returns a number value using the locale convention.

    <!--- loop through a list of locales and show number values --->
    <cfloop LIST = "#Server.Coldfusion.SupportedLocales#"
    index = "locale" delimiters = ",">
    <cfset oldlocale = setLocale(locale)>
    <cfoutput><p><b><i>#locale#</i></b><br />
    #lsNumberFormat(-1234.5678, "_________")#<br />
    #lsNumberFormat(-1234.5678, "_________.___")#<br />
    #lsNumberFormat(1234.5678, "_________")#<br />
    #lsNumberFormat(1234.5678, "_________.___")#<br />
    #lsNumberFormat(1234.5678, "$_(_________.___)")#<br />
    #lsNumberFormat(-1234.5678, "$_(_________.___)")#<br />
    #lsNumberFormat(1234.5678, "+_________.___")#<br />
    #lsNumberFormat(1234.5678, "-_________.___")#<br />
    </cfoutput>
    </cfloop>

    Script Example using specific locale

    lsNumberFormat returns a number value using the specified locale.

    writeDump(lsNumberFormat(5, '.99', 'en_US'));

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/lsnumberformat

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API