Skip to content

Commit cc4003f

Browse files
chore: Change getDeviceTime to call the mobile implementation (#1332)
1 parent 5d6cf9d commit cc4003f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/io/appium/java_client/HasDeviceTime.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818

1919
import static io.appium.java_client.MobileCommand.GET_DEVICE_TIME;
2020

21+
import com.google.common.collect.ImmutableList;
2122
import com.google.common.collect.ImmutableMap;
2223

24+
import org.openqa.selenium.remote.DriverCommand;
2325
import org.openqa.selenium.remote.Response;
2426

27+
import java.util.Map;
28+
2529
public interface HasDeviceTime extends ExecutesMethod {
2630

2731
/**
@@ -31,10 +35,15 @@ public interface HasDeviceTime extends ExecutesMethod {
3135
* https://momentjs.com/docs/ to get the full list of supported
3236
* datetime format specifiers. The default format is
3337
* `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601
38+
* @since Appium 1.18
3439
* @return Device time string
3540
*/
3641
default String getDeviceTime(String format) {
37-
Response response = execute(GET_DEVICE_TIME, ImmutableMap.of("format", format));
42+
Map<String, ?> params = ImmutableMap.of(
43+
"script", "mobile: getDeviceTime",
44+
"args", ImmutableList.of(ImmutableMap.of("format", format))
45+
);
46+
Response response = execute(DriverCommand.EXECUTE_SCRIPT, params);
3847
return response.getValue().toString();
3948
}
4049

0 commit comments

Comments
 (0)