The apex.locale namespace contains Oracle Application Express functions related to formatting numbers and dates according to a specific locale. For localizing text messages see apex.lang.
- Since:
- 20.1
Formats the given number in a compact, locale specific way. For example in the US English locale the number 123400 would be formatted as "123.4K" and 1234000 as "1.23M".
This function relies on additional resources that are loaded when the page first loads. Calling this function before the resources are loaded returns the number as an unformatted string. See apex.locale.resourcesLoaded.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pValue |
number | The number value to be formatted. | |||||||||||||||||||||||||||||||
pOptions |
object |
<optional> |
An options object that affect the way the number is formatted. All properties optional.
Properties
|
Returns:
- Type
- string
Examples
var largeNumber = 123456789.12;
var formattedNumber = apex.locale.formatCompactNumber( largeNumber );
// In the US English locale this will display: "The number is: 123.46M"
apex.message.alert( "The number is: " + formattedNumber, function() {
// do something after message is shown if needed
} );
var largeNumber = 123456789.12;
var formattedNumber = apex.locale.formatCompactNumber( largeNumber, { maximumFractionDigits: 0 } );
// In the US English locale the formattedNumber is equal to 123M"
Formats a number using a database format model similar to the SQL TO_CHAR(number)
function.
See the Oracle SQL Language reference section on Format Models for more information on the pFormat parameter. The format elements RN, TM, and EEEE are not supported.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pValue |
number | The number to format. | ||||||||||||||||
pFormat |
string |
<optional> |
The database format model. The format elements RN, TM, and EEEE are not supported. If the format is not given the number is returned as a string with no additional formatting. | |||||||||||||||
pOptions |
object |
<optional> |
Options to override default locale settings. All properties optional.
Properties
|
Returns:
- Type
- string
Example
var formattedNumber = apex.locale.formatNumber( 1234.569, "FML999G999G999G999G990D00" );
// In the US English locale this will display: "The cost is: $1,234.57"
apex.message.alert( "The cost is: " + formattedNumber, function() {
// do something after message is shown if needed
} );
Returns:
- Type
- array
Returns:
- Type
- array
Returns:
- Type
- string
Returns:
- Type
- string
Returns:
- Type
- string
Returns:
- Type
- string
Returns:
- Type
- string
Returns:
- Type
- string
Used to determine if the resources needed by some of the apex.locale functions have been loaded.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pCallback |
function |
<optional> |
A Function to call when the resources have been loaded. If the resources are already loaded the function is called right away. |
Returns:
- Type
- Promise
Examples
apex.locale.resourcesLoaded( function() {
var formattedNumber = apex.locale.formatCompactNumber( 123456789.12 );
// In the US English locale this will log: "The number is: 123.46M"
console.log( "The number is: " + formattedNumber );
} );
var p = apex.locale.resourcesLoaded();
p.done( function() {
var formattedNumber = apex.locale.formatCompactNumber( 123456789.12 );
// In the US English locale this will log: "The number is: 123.46M"
console.log( "The number is: " + formattedNumber );
} );
if ( apex.locale.resourcesLoaded().state() === "resolved" ) {
// resources are loaded
} else {
// resources are not yet loaded
}