SBM ModScript Reference → Programming SBM ModScript → Object Types → Locale → Locale Format-type-() Method
Uses locale awareness to create a text value from the number stored in "value".
string FormatInt( string value, bool useGrouping ) string FormatInt64( string value, bool useGrouping ) string FormatDouble( string value, bool useGrouping [, int minFractionDigits, int maxFractionDigits ] )
Parameter | Type | Description |
---|---|---|
value |
string |
The value to parse. |
useGrouping |
bool |
Indicates if the output string should have groupings like thousands separators; the rules for these separators are defined in the locale. |
minFractionDigits |
int |
Indicates the minimum number of digits to be printed after the decimal point. |
maxFractionDigits |
int |
Indicates the maximum number of digits to be printed after the decimal point. |
Type | Description |
---|---|
string |
The resultant text value. |
SBM ModScript version: 11.3.
var germanLocale = CreateLocale("de_DE"); var intR = germanLocale.FormatInt( 23912, false ); Ext.WriteStream( "int: result: ${intR}, expected: 23912" ); var int64R = germanLocale.FormatInt64( 52954845625ll, true ); Ext.WriteStream( "int64_t: result: ${int64R}, expected: 52.954.845.625" ); var dblR = germanLocale.FormatDouble( 1251239.2564, true, 5, 7 ); Ext.WriteStream( "double: result: ${dblR}, expected: 1.251.239,25640" );
Result:
int: result: 23912, expected: 23912 int64_t: result: 52.954.845.625, expected: 52.954.845.625 double: result: 1.251.239,25640, expected: 1.251.239,25640
maxFractionDigits must be >= minFractionDigits. If the value for maxFractionDigits is less than the value of minFractionDigits, then maxFractionDigits will be set to the value of minFractionDigits. Use -1 to indicate default behavior if only minFractionDigits or maxFractionDigits should be specified.
Copyright © 2007–2018 Serena Software, Inc., a Micro Focus company. All rights reserved.