# Global.String
The JavaScript built-in String type.
# Overview
This module contains Titanium-only extensions for formatting data into locale-specific strings. The target locale is configured by the user in the device's system Settings.
# Methods
# format
Formats a string using printf
-style substitution.
The format string follows the IEEE printf specification.
For each "conversion specification" (ie. %s
for a string or %d
for a number) used inside
the string, formatString
argument, the respective value is substituted from the
argument list. For example:
var forename = 'Paul';
var number = 21;
var message = String.format('Welcome, %s! You are visitor number %d', forename, number);
Ti.API.info(message);
Parameters
Name | Type | Description |
---|---|---|
formatString | String | An IEEE |
value | String | Number | Values to substitute into the |
Returns
Formatted string.
- Type
- String
# formatCurrency
Formats a number into the currency format, including currency symbol, of the locale configured for the system.
Parameters
Name | Type | Description |
---|---|---|
value | Number | Currency value. |
Returns
Formatted, localized string.
- Type
- String
# formatDate
Formats a date into the date format of the locale configured for the system.
Parameters
Name | Type | Description |
---|---|---|
date | Date | Date to format. |
format | String | Date format to use. One of 'short', 'medium', 'long' or 'full'. |
Returns
Formatted, localized string.
- Type
- String
# formatDecimal
Formats a number into the decimal format, including decimal symbol, of the locale configured for the system.
The localized string created by this method can be parsed be parsed back to a number via the parseDecimal method.
Parameters
Name | Type | Description |
---|---|---|
value | Number | Value to format. |
locale | String | Locale string. For example, |
pattern | String | Format pattern. |
Returns
String representation of the specified number, using a locale-specific decimal symbol, if required.
- Type
- String
# formatTime
Formats a date into the time format of the locale configured for the system.
On Android, this method returns the short format.
Parameters
Name | Type | Description |
---|---|---|
date | Date | Date to format. |
format | String | Date format to use. One of 'short', 'medium', or 'long' (iOS only.) |
Returns
Formatted, localized string.
- Type
- String