未验证 提交 e718a0db 编写于 作者: O openharmony_ci 提交者: Gitee

!4058 3482 处理完成:增加示例代码语言类型及修改样式

Merge pull request !4058 from ester.zhou/TR-3482
# Input Method Framework # Input Method Framework
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
...@@ -40,16 +40,18 @@ Obtains an [InputMethodController](#InputMethodController) instance. ...@@ -40,16 +40,18 @@ Obtains an [InputMethodController](#InputMethodController) instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.| | [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.|
**Example**
```
var InputMethodController = inputMethod.getInputMethodController();
```
- Example
```
var InputMethodController = inputMethod.getInputMethodController();
```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a> ## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
getInputMethodSetting(): InputMethodSetting getInputMethodSetting(): InputMethodSetting
...@@ -58,17 +60,17 @@ Obtains an [InputMethodSetting](#InputMethodSetting) instance. ...@@ -58,17 +60,17 @@ Obtains an [InputMethodSetting](#InputMethodSetting) instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------- | ---------------------------- | | ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.| | [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.|
**Example**
- Example ```js
``` var InputMethodSetting = inputMethod.getInputMethodSetting();
var InputMethodSetting = inputMethod.getInputMethodSetting(); ```
```
## InputMethodController<a name="InputMethodController"></a> ## InputMethodController<a name="InputMethodController"></a>
...@@ -82,15 +84,15 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. ...@@ -82,15 +84,15 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the keyboard is successfully hidden.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the keyboard is successfully hidden.|
- Example **Example**
``` ```js
InputMethodController.stopInput((error)=>{ InputMethodController.stopInput((error)=>{
console.info('stopInput'); console.info('stopInput');
}); });
...@@ -104,16 +106,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. ...@@ -104,16 +106,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the keyboard is successfully hidden.| | Promise&lt;boolean&gt; | Promise used to return whether the keyboard is successfully hidden.|
- Example **Example**
``` ```js
var isSuccess = InputMethodController.stopInput(); var isSuccess = InputMethodController.stopInput();
console.info('stopInput isSuccess = ' + isSuccess); console.info('stopInput isSuccess = ' + isSuccess);
``` ```
...@@ -130,20 +132,22 @@ Obtains the list of installed input methods. This API uses an asynchronous callb ...@@ -130,20 +132,22 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | ---------------------- | | Name | Type | Mandatory| Description |
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.| | -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.|
- Example
``` **Example**
InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) { ```js
var property = properties[i]; InputMethodSetting.listInputMethod((properties)=>{
console.info(property.packageName + "/" + property.methodId); for (var i = 0;i < properties.length; i++) {
} var property = properties[i];
}); console.info(property.packageName + "/" + property.methodId);
``` }
});
```
### listInputMethod ### listInputMethod
...@@ -153,19 +157,21 @@ Obtains the list of installed input methods. This API uses an asynchronous callb ...@@ -153,19 +157,21 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | Promise used to return the list of installed input methods.|
- Example | Type | Description |
``` | ----------------------------------------------------------- | ---------------------- |
var properties = InputMethodSetting.listInputMethod(); | Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | Promise used to return the list of installed input methods.|
for (var i = 0;i < properties.length; i++) {
var property = properties[i]; **Example**
console.info(property.packageName + "/" + property.methodId);
} ```js
``` var properties = InputMethodSetting.listInputMethod();
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
console.info(property.packageName + "/" + property.methodId);
}
```
### displayOptionalInputMethod ### displayOptionalInputMethod
...@@ -181,12 +187,12 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono ...@@ -181,12 +187,12 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
``` ```js
InputMethodSetting.displayOptionalInputMethod(()=>{ InputMethodSetting.displayOptionalInputMethod(()=>{
console.info('displayOptionalInputMethod is called'); console.info('displayOptionalInputMethod is called');
}); });
``` ```
### displayOptionalInputMethod ### displayOptionalInputMethod
...@@ -194,15 +200,16 @@ displayOptionalInputMethod(): Promise&lt;void&gt; ...@@ -194,15 +200,16 @@ displayOptionalInputMethod(): Promise&lt;void&gt;
Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result. Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```
InputMethodSetting.displayOptionalInputMethod(); ```js
``` InputMethodSetting.displayOptionalInputMethod();
```
\ No newline at end of file
# Setting the System Time # Setting the System Time
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
``` ```
import systemTime from '@ohos.systemTime'; import systemTime from '@ohos.systemTime';
``` ```
...@@ -22,16 +22,17 @@ Sets the system time. This API uses an asynchronous callback to return the resul ...@@ -22,16 +22,17 @@ Sets the system time. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| time | number | Yes| Timestamp to set, in milliseconds.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | time | number | Yes| Timestamp to set, in milliseconds.|
// Set the system time to 2021-01-20 02:36:25. | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
**Example**
```js
// Set the system time to 2021-01-20 02:36:25.
var time = 1611081385000; var time = 1611081385000;
systemTime.setTime(time, (error, data) => { systemTime.setTime(time, (error, data) => {
if (error) { if (error) {
...@@ -53,26 +54,28 @@ Sets the system time. This API uses a promise to return the result. ...@@ -53,26 +54,28 @@ Sets the system time. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| time | number | Yes| Timestamp to set, in milliseconds.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | time | number | Yes| Timestamp to set, in milliseconds.|
| Promise&lt;void&gt; | Promise used to return the result.|
- Example **Return value**
``` | Type| Description|
// Set the system time to 2021-01-20 02:36:25. | -------- | -------- |
var time = 1611081385000; | Promise&lt;void&gt; | Promise used to return the result.|
systemTime.setTime(time).then((data) => {
console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); **Example**
}).catch((error) => {
console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); ```js
}); // Set the system time to 2021-01-20 02:36:25.
var time = 1611081385000;
systemTime.setTime(time).then((data) => {
console.log(`systemTime.setTime success data : ` + JSON.stringify(data));
}).catch((error) => {
console.error(`failed to systemTime.setTime because ` + JSON.stringify(error));
});
``` ```
...@@ -84,15 +87,16 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal ...@@ -84,15 +87,16 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
**Example**
```js
systemTime.getCurrentTime(true, (error, data) => { systemTime.getCurrentTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
...@@ -111,19 +115,21 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return ...@@ -111,19 +115,21 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| Promise&lt;number&gt; | Promise used to return the time.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
**Example**
```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -140,15 +146,16 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This ...@@ -140,15 +146,16 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
**Example**
```js
systemTime.getRealActiveTime(true, (error, data) => { systemTime.getRealActiveTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error));
...@@ -167,19 +174,21 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This ...@@ -167,19 +174,21 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| Promise&lt;number&gt; | Promise used to return the time.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
**Example**
```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -196,15 +205,16 @@ Obtains the time elapsed since system start, including the deep sleep time. This ...@@ -196,15 +205,16 @@ Obtains the time elapsed since system start, including the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
**Example**
```js
systemTime.getRealTime(true, (error, data) => { systemTime.getRealTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
...@@ -223,19 +233,21 @@ Obtains the time elapsed since system start, including the deep sleep time. This ...@@ -223,19 +233,21 @@ Obtains the time elapsed since system start, including the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| Promise&lt;number&gt; | Promise used to return the time.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
**Example**
```js
systemTime.getRealTime().then((data) => { systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -254,15 +266,16 @@ Sets the system date. This API uses an asynchronous callback to return the resul ...@@ -254,15 +266,16 @@ Sets the system date. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | Yes| Target date to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | date | Date | Yes| Target date to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
**Example**
```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => { systemTime.setDate(data,(error, data) => {
if (error) { if (error) {
...@@ -284,19 +297,21 @@ Sets the system date. This API uses a promise to return the result. ...@@ -284,19 +297,21 @@ Sets the system date. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | Yes| Target date to set.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | date | Date | Yes| Target date to set.|
| Promise&lt;void&gt; | Promise used to return the result.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data).then((value) => { systemTime.setDate(data).then((value) => {
console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); console.log(`systemTime.setDate success data : ` + JSON.stringify(value));
...@@ -314,14 +329,15 @@ Obtains the current system date. This API uses an asynchronous callback to retur ...@@ -314,14 +329,15 @@ Obtains the current system date. This API uses an asynchronous callback to retur
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Date&gt; | Yes| Callback used to return the current system date.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | callback | AsyncCallback&lt;Date&gt; | Yes| Callback used to return the current system date.|
**Example**
```js
systemTime.getDate((error, data) => { systemTime.getDate((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));
...@@ -340,14 +356,15 @@ Obtains the current system date. This API uses a promise to return the result. ...@@ -340,14 +356,15 @@ Obtains the current system date. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Date&gt; | Promise used to return the current system date.|
- Example | Type| Description|
| -------- | -------- |
``` | Promise&lt;Date&gt; | Promise used to return the current system date.|
**Example**
```js
systemTime.getDate().then((data) => { systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -366,15 +383,16 @@ Sets the system time zone. This API uses an asynchronous callback to return the ...@@ -366,15 +383,16 @@ Sets the system time zone. This API uses an asynchronous callback to return the
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timezone | string | Yes| System time zone to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | timezone | string | Yes| System time zone to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
**Example**
```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => { systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (error) { if (error) {
console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error));
...@@ -395,19 +413,21 @@ Sets the system time zone. This API uses a promise to return the result. ...@@ -395,19 +413,21 @@ Sets the system time zone. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timezone | string | Yes| System time zone to set.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | timezone | string | Yes| System time zone to set.|
| Promise&lt;void&gt; | Promise used to return the result.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
systemTime.setTimezone('Asia/Shanghai').then((data) => { systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -424,14 +444,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t ...@@ -424,14 +444,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the system time zone.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
``` | callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the system time zone.|
**Example**
```js
systemTime.getTimezone((error, data) => { systemTime.getTimezone((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
...@@ -450,14 +471,15 @@ Obtains the system time zone. This API uses a promise to return the result. ...@@ -450,14 +471,15 @@ Obtains the system time zone. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the system time zone.|
- Example | Type| Description|
| -------- | -------- |
``` | Promise&lt;string&gt; | Promise used to return the system time zone.|
**Example**
```js
systemTime.getTimezone().then((data) => { systemTime.getTimezone().then((data) => {
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册