2016-08-23 198 views
2

我有類似的問題,例如herehere。我也在使用XML視圖。有了這個代碼SAPUI5:格式化日期字段(Odata)

<Text text="{ path: 'model1>CHANGE_DATE' }" />  

我得到follwowing輸出:

/Date(1671944676355)/ 

當我嘗試

<Text text="{ path: 'model1>CHANGE_DATE', 
       type: 'sap.ui.model.type.Date', 
       formatOptions: { pattern: 'MM/dd/yyyy' } }" />, 

我收到錯誤消息

sap-ui-core-dbg.js:30928 Uncaught TypeError: oDate.getTime is not a function

你有任何愛迪爲什麼格式不起作用?

在此先感謝。

問候

+0

這是一個ODataModel嗎?該字段是否被聲明爲Edm.DateTime? – cschuff

+0

好的。我正在使用JsonModel。也許這就是原因。如有必要,我可以嘗試轉換爲OdataModel。 –

+0

猜猜這是原因。您也可以切換到另一種日期格式或使用格式化函數將字符串轉換爲JS Date對象 – cschuff

回答

1

轉換爲ODataModel解決了這個問題。