Globalization
Imported Modules
import Intl from '@ohos.intl';
Permissions
None.
Class
Locale
Provides APIs for obtaining locale information.
Attributes
Indicates the basic locale information, which is returned as a substring of a complete locale string. |
Locale
A constructor used to create a Locale object.
Parameters
Indicates a character string containing the locale information, including the language and optionally the script and region. |
Example
var enLatnGB = new Intl.Locale("en-Latn-GB");
var enGB = new Intl.Locale("en-GB");
var en = new Intl.Locale("en");
DateTimeFormat
Provides the API for formatting date strings.
DateTimeFormat
A constructor used to create a DateTimeFormat object.
Parameters
Indicates a character string containing the locale information, including the language and optionally the script and region, for the DateTimeFormat object. |
Example
var dateFmt = new Intl.DateTimeFormat("en-Latn-GB");
format
Obtains the formatted date strings.
Parameters
Return Values
Indicates a date string formatted based on the specified locale. |
Example
var date = new Date(1995, 11, 25, 3, 14, 0);
var datefmt = new Intl.DateTimeFormat("en-Latn-GB");
var result = datefmt.format(date); // The formatted date string is Dec 25, 1995.