1# Globalization<a name="EN-US_TOPIC_0000001115814852"></a> 2 3- [Imported Modules](#en-us_topic_0000001103315838_s56d19203690d4782bfc74069abb6bd71) 4- [Permissions](#en-us_topic_0000001103315838_section11257113618419) 5- [Class](#en-us_topic_0000001103315838_section1956131218111) 6- [Locale](#en-us_topic_0000001103315838_section189341937163212) 7 - [Attributes](#en-us_topic_0000001103315838_section23751576140) 8 - [Locale](#en-us_topic_0000001103315838_section1410593619146) 9 10- [DateTimeFormat](#en-us_topic_0000001103315838_section88061769522) 11 - [DateTimeFormat](#en-us_topic_0000001103315838_section28081362523) 12 - [format](#en-us_topic_0000001103315838_section917151185514) 13 14 15## Imported Modules<a name="en-us_topic_0000001103315838_s56d19203690d4782bfc74069abb6bd71"></a> 16 17``` 18import Intl from '@ohos.intl'; 19``` 20 21## Permissions<a name="en-us_topic_0000001103315838_section11257113618419"></a> 22 23None. 24 25## Class<a name="en-us_topic_0000001103315838_section1956131218111"></a> 26 27## Locale<a name="en-us_topic_0000001103315838_section189341937163212"></a> 28 29Provides APIs for obtaining locale information. 30 31### Attributes<a name="en-us_topic_0000001103315838_section23751576140"></a> 32 33<a name="en-us_topic_0000001103315838_table728861911417"></a> 34<table><thead align="left"><tr id="en-us_topic_0000001103315838_row62887198149"><th class="cellrowborder" valign="top" width="15.870000000000001%" id="mcps1.1.6.1.1"><p id="en-us_topic_0000001103315838_p928811911410"><a name="en-us_topic_0000001103315838_p928811911410"></a><a name="en-us_topic_0000001103315838_p928811911410"></a>Name</p> 35</th> 36<th class="cellrowborder" valign="top" width="10.86%" id="mcps1.1.6.1.2"><p id="en-us_topic_0000001103315838_p8288191916149"><a name="en-us_topic_0000001103315838_p8288191916149"></a><a name="en-us_topic_0000001103315838_p8288191916149"></a>Type</p> 37</th> 38<th class="cellrowborder" valign="top" width="9.34%" id="mcps1.1.6.1.3"><p id="en-us_topic_0000001103315838_p14288131911418"><a name="en-us_topic_0000001103315838_p14288131911418"></a><a name="en-us_topic_0000001103315838_p14288131911418"></a>Readable</p> 39</th> 40<th class="cellrowborder" valign="top" width="11.51%" id="mcps1.1.6.1.4"><p id="en-us_topic_0000001103315838_p1928861921411"><a name="en-us_topic_0000001103315838_p1928861921411"></a><a name="en-us_topic_0000001103315838_p1928861921411"></a>Writable</p> 41</th> 42<th class="cellrowborder" valign="top" width="52.42%" id="mcps1.1.6.1.5"><p id="en-us_topic_0000001103315838_p728815191149"><a name="en-us_topic_0000001103315838_p728815191149"></a><a name="en-us_topic_0000001103315838_p728815191149"></a>Description</p> 43</th> 44</tr> 45</thead> 46<tbody><tr id="en-us_topic_0000001103315838_row528891919142"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p3288191991414"><a name="en-us_topic_0000001103315838_p3288191991414"></a><a name="en-us_topic_0000001103315838_p3288191991414"></a>language</p> 47</td> 48<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p3288121901418"><a name="en-us_topic_0000001103315838_p3288121901418"></a><a name="en-us_topic_0000001103315838_p3288121901418"></a>string</p> 49</td> 50<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p182881319191414"><a name="en-us_topic_0000001103315838_p182881319191414"></a><a name="en-us_topic_0000001103315838_p182881319191414"></a>Yes</p> 51</td> 52<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1928801914148"><a name="en-us_topic_0000001103315838_p1928801914148"></a><a name="en-us_topic_0000001103315838_p1928801914148"></a>No</p> 53</td> 54<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p1428811192144"><a name="en-us_topic_0000001103315838_p1428811192144"></a><a name="en-us_topic_0000001103315838_p1428811192144"></a>Indicates the language of the locale.</p> 55</td> 56</tr> 57<tr id="en-us_topic_0000001103315838_row11288719111417"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p10288419131415"><a name="en-us_topic_0000001103315838_p10288419131415"></a><a name="en-us_topic_0000001103315838_p10288419131415"></a>script</p> 58</td> 59<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p91710563611"><a name="en-us_topic_0000001103315838_p91710563611"></a><a name="en-us_topic_0000001103315838_p91710563611"></a>string</p> 60</td> 61<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p14171165163611"><a name="en-us_topic_0000001103315838_p14171165163611"></a><a name="en-us_topic_0000001103315838_p14171165163611"></a>Yes</p> 62</td> 63<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1017115543612"><a name="en-us_topic_0000001103315838_p1017115543612"></a><a name="en-us_topic_0000001103315838_p1017115543612"></a>No</p> 64</td> 65<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p3171125183610"><a name="en-us_topic_0000001103315838_p3171125183610"></a><a name="en-us_topic_0000001103315838_p3171125183610"></a>Indicates the script of the locale.</p> 66</td> 67</tr> 68<tr id="en-us_topic_0000001103315838_row19687050183612"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p32281883406"><a name="en-us_topic_0000001103315838_p32281883406"></a><a name="en-us_topic_0000001103315838_p32281883406"></a>region</p> 69</td> 70<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p1522810854016"><a name="en-us_topic_0000001103315838_p1522810854016"></a><a name="en-us_topic_0000001103315838_p1522810854016"></a>string</p> 71</td> 72<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p1422858124014"><a name="en-us_topic_0000001103315838_p1422858124014"></a><a name="en-us_topic_0000001103315838_p1422858124014"></a>Yes</p> 73</td> 74<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1922817874013"><a name="en-us_topic_0000001103315838_p1922817874013"></a><a name="en-us_topic_0000001103315838_p1922817874013"></a>No</p> 75</td> 76<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p1722818834016"><a name="en-us_topic_0000001103315838_p1722818834016"></a><a name="en-us_topic_0000001103315838_p1722818834016"></a>Indicates the region of the locale.</p> 77</td> 78</tr> 79<tr id="en-us_topic_0000001103315838_row115871535369"><td class="cellrowborder" valign="top" width="15.870000000000001%" headers="mcps1.1.6.1.1 "><p id="en-us_topic_0000001103315838_p15801188114019"><a name="en-us_topic_0000001103315838_p15801188114019"></a><a name="en-us_topic_0000001103315838_p15801188114019"></a>baseName</p> 80</td> 81<td class="cellrowborder" valign="top" width="10.86%" headers="mcps1.1.6.1.2 "><p id="en-us_topic_0000001103315838_p108011082401"><a name="en-us_topic_0000001103315838_p108011082401"></a><a name="en-us_topic_0000001103315838_p108011082401"></a>string</p> 82</td> 83<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="en-us_topic_0000001103315838_p138011980407"><a name="en-us_topic_0000001103315838_p138011980407"></a><a name="en-us_topic_0000001103315838_p138011980407"></a>Yes</p> 84</td> 85<td class="cellrowborder" valign="top" width="11.51%" headers="mcps1.1.6.1.4 "><p id="en-us_topic_0000001103315838_p1980128134011"><a name="en-us_topic_0000001103315838_p1980128134011"></a><a name="en-us_topic_0000001103315838_p1980128134011"></a>No</p> 86</td> 87<td class="cellrowborder" valign="top" width="52.42%" headers="mcps1.1.6.1.5 "><p id="en-us_topic_0000001103315838_p1801208144012"><a name="en-us_topic_0000001103315838_p1801208144012"></a><a name="en-us_topic_0000001103315838_p1801208144012"></a>Indicates the basic locale information, which is returned as a substring of a complete locale string.</p> 88</td> 89</tr> 90</tbody> 91</table> 92 93### Locale<a name="en-us_topic_0000001103315838_section1410593619146"></a> 94 95A constructor used to create a **Locale** object. 96 97**Parameters** 98 99<a name="en-us_topic_0000001103315838_table114831131512"></a> 100<table><thead align="left"><tr id="en-us_topic_0000001103315838_row914851141517"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001103315838_p214819113159"><a name="en-us_topic_0000001103315838_p214819113159"></a><a name="en-us_topic_0000001103315838_p214819113159"></a>Name</p> 101</th> 102<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001103315838_p1214921121519"><a name="en-us_topic_0000001103315838_p1214921121519"></a><a name="en-us_topic_0000001103315838_p1214921121519"></a>Type</p> 103</th> 104<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001103315838_p11491711141512"><a name="en-us_topic_0000001103315838_p11491711141512"></a><a name="en-us_topic_0000001103315838_p11491711141512"></a>Mandatory</p> 105</th> 106<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001103315838_p171491011171512"><a name="en-us_topic_0000001103315838_p171491011171512"></a><a name="en-us_topic_0000001103315838_p171491011171512"></a>Description</p> 107</th> 108</tr> 109</thead> 110<tbody><tr id="en-us_topic_0000001103315838_row91491211131519"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001103315838_p45271354164919"><a name="en-us_topic_0000001103315838_p45271354164919"></a><a name="en-us_topic_0000001103315838_p45271354164919"></a>locale</p> 111</td> 112<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001103315838_p1252795444917"><a name="en-us_topic_0000001103315838_p1252795444917"></a><a name="en-us_topic_0000001103315838_p1252795444917"></a>string</p> 113</td> 114<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001103315838_p314916118154"><a name="en-us_topic_0000001103315838_p314916118154"></a><a name="en-us_topic_0000001103315838_p314916118154"></a>Yes</p> 115</td> 116<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001103315838_p814951171516"><a name="en-us_topic_0000001103315838_p814951171516"></a><a name="en-us_topic_0000001103315838_p814951171516"></a>Indicates a character string containing the locale information, including the language and optionally the script and region.</p> 117</td> 118</tr> 119</tbody> 120</table> 121 122**Example** 123 124``` 125var enLatnGB = new Intl.Locale("en-Latn-GB"); 126var enGB = new Intl.Locale("en-GB"); 127var en = new Intl.Locale("en"); 128``` 129 130## DateTimeFormat<a name="en-us_topic_0000001103315838_section88061769522"></a> 131 132Provides the API for formatting date strings. 133 134### DateTimeFormat<a name="en-us_topic_0000001103315838_section28081362523"></a> 135 136A constructor used to create a **DateTimeFormat** object. 137 138**Parameters** 139 140<a name="en-us_topic_0000001103315838_table1680806175216"></a> 141<table><thead align="left"><tr id="en-us_topic_0000001103315838_row10808868524"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001103315838_p108080625215"><a name="en-us_topic_0000001103315838_p108080625215"></a><a name="en-us_topic_0000001103315838_p108080625215"></a>Name</p> 142</th> 143<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001103315838_p78089645215"><a name="en-us_topic_0000001103315838_p78089645215"></a><a name="en-us_topic_0000001103315838_p78089645215"></a>Type</p> 144</th> 145<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001103315838_p17808126175217"><a name="en-us_topic_0000001103315838_p17808126175217"></a><a name="en-us_topic_0000001103315838_p17808126175217"></a>Mandatory</p> 146</th> 147<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001103315838_p15808106185212"><a name="en-us_topic_0000001103315838_p15808106185212"></a><a name="en-us_topic_0000001103315838_p15808106185212"></a>Description</p> 148</th> 149</tr> 150</thead> 151<tbody><tr id="en-us_topic_0000001103315838_row19808116205213"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001103315838_p880815616525"><a name="en-us_topic_0000001103315838_p880815616525"></a><a name="en-us_topic_0000001103315838_p880815616525"></a>locale</p> 152</td> 153<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001103315838_p18091655211"><a name="en-us_topic_0000001103315838_p18091655211"></a><a name="en-us_topic_0000001103315838_p18091655211"></a>string</p> 154</td> 155<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001103315838_p19809196105217"><a name="en-us_topic_0000001103315838_p19809196105217"></a><a name="en-us_topic_0000001103315838_p19809196105217"></a>Yes</p> 156</td> 157<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001103315838_p28095613525"><a name="en-us_topic_0000001103315838_p28095613525"></a><a name="en-us_topic_0000001103315838_p28095613525"></a>Indicates a character string containing the locale information, including the language and optionally the script and region, for the <strong id="en-us_topic_0000001103315838_b06014570014"><a name="en-us_topic_0000001103315838_b06014570014"></a><a name="en-us_topic_0000001103315838_b06014570014"></a>DateTimeFormat</strong> object.</p> 158</td> 159</tr> 160</tbody> 161</table> 162 163**Example** 164 165``` 166var dateFmt = new Intl.DateTimeFormat("en-Latn-GB"); 167``` 168 169### format<a name="en-us_topic_0000001103315838_section917151185514"></a> 170 171Obtains the formatted date strings. 172 173**Parameters** 174 175<a name="en-us_topic_0000001103315838_table61711165519"></a> 176<table><thead align="left"><tr id="en-us_topic_0000001103315838_row1176115554"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001103315838_p017312552"><a name="en-us_topic_0000001103315838_p017312552"></a><a name="en-us_topic_0000001103315838_p017312552"></a>Name</p> 177</th> 178<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001103315838_p217112554"><a name="en-us_topic_0000001103315838_p217112554"></a><a name="en-us_topic_0000001103315838_p217112554"></a>Type</p> 179</th> 180<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001103315838_p61771165517"><a name="en-us_topic_0000001103315838_p61771165517"></a><a name="en-us_topic_0000001103315838_p61771165517"></a>Mandatory</p> 181</th> 182<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001103315838_p418515559"><a name="en-us_topic_0000001103315838_p418515559"></a><a name="en-us_topic_0000001103315838_p418515559"></a>Description</p> 183</th> 184</tr> 185</thead> 186<tbody><tr id="en-us_topic_0000001103315838_row121811118556"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001103315838_p13181419559"><a name="en-us_topic_0000001103315838_p13181419559"></a><a name="en-us_topic_0000001103315838_p13181419559"></a>date</p> 187</td> 188<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001103315838_p918171185515"><a name="en-us_topic_0000001103315838_p918171185515"></a><a name="en-us_topic_0000001103315838_p918171185515"></a>Date</p> 189</td> 190<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001103315838_p161819114551"><a name="en-us_topic_0000001103315838_p161819114551"></a><a name="en-us_topic_0000001103315838_p161819114551"></a>Yes</p> 191</td> 192<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001103315838_p718316555"><a name="en-us_topic_0000001103315838_p718316555"></a><a name="en-us_topic_0000001103315838_p718316555"></a>Indicates the <strong id="en-us_topic_0000001103315838_b89491740312"><a name="en-us_topic_0000001103315838_b89491740312"></a><a name="en-us_topic_0000001103315838_b89491740312"></a>Date</strong> object to be formatted.</p> 193</td> 194</tr> 195</tbody> 196</table> 197 198**Return Values** 199 200<a name="en-us_topic_0000001103315838_table2187195518"></a> 201<table><thead align="left"><tr id="en-us_topic_0000001103315838_row618171115511"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="en-us_topic_0000001103315838_p12186185510"><a name="en-us_topic_0000001103315838_p12186185510"></a><a name="en-us_topic_0000001103315838_p12186185510"></a>Type</p> 202</th> 203<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="en-us_topic_0000001103315838_p218171115514"><a name="en-us_topic_0000001103315838_p218171115514"></a><a name="en-us_topic_0000001103315838_p218171115514"></a>Description</p> 204</th> 205</tr> 206</thead> 207<tbody><tr id="en-us_topic_0000001103315838_row13181115555"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="en-us_topic_0000001103315838_p3195145512"><a name="en-us_topic_0000001103315838_p3195145512"></a><a name="en-us_topic_0000001103315838_p3195145512"></a>string</p> 208</td> 209<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="en-us_topic_0000001103315838_p3196119551"><a name="en-us_topic_0000001103315838_p3196119551"></a><a name="en-us_topic_0000001103315838_p3196119551"></a>Indicates a date string formatted based on the specified locale.</p> 210</td> 211</tr> 212</tbody> 213</table> 214 215**Example** 216 217``` 218var date = new Date(1995, 11, 25, 3, 14, 0); 219var datefmt = new Intl.DateTimeFormat("en-Latn-GB"); 220var result = datefmt.format(date); // The formatted date string is Dec 25, 1995. 221``` 222 223