# Globalization ## Imported Modules ``` import Intl from '@ohos.intl'; ``` ## Permissions None. ## Class ## Locale Provides APIs for obtaining locale information. ### Attributes

Name

Type

Readable

Writable

Description

language

string

Yes

No

Indicates the language of the locale.

script

string

Yes

No

Indicates the script of the locale.

region

string

Yes

No

Indicates the region of the locale.

baseName

string

Yes

No

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**

Name

Type

Mandatory

Description

locale

string

Yes

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**

Name

Type

Mandatory

Description

locale

string

Yes

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**

Name

Type

Mandatory

Description

date

Date

Yes

Indicates the Date object to be formatted.

**Return Values**

Type

Description

string

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. ```