Sahi Pro - 无法将日期格式从 "Thursday 02 Mar 2017" 更改为 "MM/DD/YYYY"

Sahi Pro - not able to change date format from "Thursday 02 Mar 2017" to "MM/DD/YYYY"

我正在尝试使用以下代码在 Sahi Pro 中转换日期格式,但没有成功:

我想将 "Thursday 02 Mar 2017" 转换为“03/02/2017”

_setValue(_textbox("j_username"), "*******");
_setValue(_password("j_password"), "*******");
_click(_span("Login"));
_click(_span("Home"));

_wait(2000);

var $date = _getText(_div("/date-display .* bwc-selected/"));

_wait(2000);

_log($date);

_wait(2000);

var $date = _getText(_div("/date-display .* bwc-selected/"));
var $old_date_format = new java.text.SimpleDateFormat(_getText(_div("/date-display .* bwc-selected/"))).parse($date);
var $converted_date_format = new java.text.SimpleDateFormat("MM/dd/yyyy").format($old_date_format);

_log($converted_date_format);

在 运行 上面的代码之后,我收到以下格式化 fate 的错误:

Wrapped java.lang.IllegalArgumentException: Illegal pattern character 'T' (C:\SahiPro\userdata\scripts\Trial.sah#11)

我对 Java 脚本做了一些研究并提出了以下解决方案:

以下代码将 "Thursday 02 Mar 2017" 转换为“03/02/2017”

var $date = _getText(_div("/date-display .* bwc-selected/"));

_wait(2000);

_log($date);

_wait(2000);

var str = ($date)

var d = new Date(str)

var $systemDate = (d.getUTCMonth()+1) +"/"+ d.getUTCDate() + "/" + d.getUTCFullYear();

_log($systemDate);