0
私はyyyy-MM-dd
で整形された日付を文字列として持ち、それをstyle:"short"
として整形したいとします。 Dateformat
を使用したいだけです。SAPUI5 - Dateformat - Dateformatで日付をフォーマットする方法
の使い方については、https://openui5.hana.ondemand.com/#docs/guide/91f2eba36f4d1014b6dd926db0e91070.htmlを使用しました。
しかし、私は私のコードで間違っているものを、見ることができない。
date: function(sdate) {
var regex = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
if (!sdate.match(regex))
return "no valid date given";
jQuery.sap.require("sap.ui.core.format.DateFormat");
var oDateFormat = sap.ui.core.format.DateFormat.getInstance({pattern: "yyyy-MM-dd", style: "short"});
return oDateFormat.format(sdate); //date should be returned here in "short"-style
}
コンソールは私 TypeError: j.getTime is not a function
です教えてください。 また、WebIDEが関数Datetime.format()
を知らないようです。
お手伝いできますか?
あなたの 'sdate'は' String'オブジェクトだと思いますが、JavaScriptの 'Date'オブジェクトである必要があります – Qualiture
[リンク](https://openui5.hana.ondemand.com/#docs/guide/91f2eba36f4d1014b6dd926db0e91070。 html):この行の 'oField.setValue(oDateFormat.format(oDate));' oDateはJavascriptです。 – Michael