1# User Preference Setting (for System Applications Only) 2 3## Use Cases 4 5In addition to system locales and application preferred languages, the system supports setting of user preferences. Currently, the system supports two user preferences: whether to use local digits and whether to use the 12/24-hour format. User preference settings are saved to system locales and application preferred languages as part of the internationalization feature. 6 7## How to Develop 8 9For details about how to use the APIs, see [setUsingLocalDigit](../reference/apis-localization-kit/js-apis-i18n-sys.md#setusinglocaldigit9) and [set24HourClock](../reference/apis-localization-kit/js-apis-i18n-sys.md#set24hourclock9). 10 11 121. Import the **intl** module. 13 ```ts 14 import { i18n, intl } from '@kit.LocalizationKit'; 15 import { BusinessError } from '@kit.BasicServicesKit'; 16 ``` 17 182. Obtain the preferred language of an application. 19 ```ts 20 // Obtain the preferred language of an application. 21 let appPreferredLanguage: string = i18n.System.getAppPreferredLanguage(); 22 ``` 23 243. Enable display of local digits on the application page. 25 ```ts 26 try { 27 i18n.System.setUsingLocalDigit(true); // Enable the local digit switch. 28 } catch(error) { 29 let err: BusinessError = error as BusinessError; 30 console.error(`call System.setUsingLocalDigit failed, error code: ${err.code}, message: ${err.message}.`); 31 } 32 let date = new Date(2023, 9, 25); 33 let appPreferredLanguage = "ar"; 34 let dateTimeFmt = new intl.DateTimeFormat(appPreferredLanguage); 35 let result = dateTimeFmt.format(date); // result = "٢٠٢٣/١٠/٢٥" (local Arabic digits) 36 ``` 37 384. Set the 24-hour clock format. 39 ```ts 40 try { 41 i18n.System.set24HourClock(true); // true means to enable the 24-hour clock, and false means to enable the 12-hour clock. 42 } catch(error) { 43 let err: BusinessError = error as BusinessError; 44 console.error(`call System.set24HourClock failed, error code: ${err.code}, message: ${err.message}.`); 45 } 46 let date = new Date(2023, 9, 25, 16, 48, 0); 47 let appPreferredLanguage = "zh"; 48 let dateTimeFmt = new intl.DateTimeFormat(appPreferredLanguage, { timeStyle: "medium" }); 49 let result = dateTimeFmt.format(date); // result = "16:48:00" 50 ``` 51