问题描述
我已经使用SAPUI5创建了一个表,并使用ODATA服务将数据获取到该表中. BUt,我有一列类型为DATE
的列,其格式类似于此"Thu Jan 13 2011 01:00:00 GMT+0100 (Mitteleuropäische Zeit)"
.
I have created a table using SAPUI5 and I get the data to the table using ODATA service. BUt, I have a column which is of a type DATE
and the format is something like this "Thu Jan 13 2011 01:00:00 GMT+0100 (Mitteleuropäische Zeit)"
.
我尝试谷歌搜索,发现这个博客,真是太好了.
I tried to google and I found this blog which is really nice.
但是在这里我也看到一个 jsbin 示例,其中仅使用了一个数据值.但是我需要选择整个整列"Businessdate
",并将其格式化为类似"13.01.2014"的格式.有什么建议吗?
But here I see also a jsbin example where only a single data value has been used. But I need to select one whole column "Businessdate
" and format it to something like this ´13.01.2014´. Any suggestions?
我的源表中的数据是DATE
类型.
The data in my source table is of type DATE
.
谢谢
推荐答案
我已经更新了您的jsbin示例: http ://jsbin.com/cika/4/edit
I have updated your jsbin example: http://jsbin.com/cika/4/edit
我所做的更改:
-
我通过将ODate日期的ISO8601格式设置为当前日期来模仿它:
I have mimicked your ODate date's ISO8601 format by just setting it to the current date:
oModel.setData({
dateValue: new Date() // I.e. Mon Feb 24 2014 17:35:22 GMT+0100 (W. Europe Standard Time)
});
只需让DatePicker控件将其格式化为所需的输出格式('dd-MM-yyyy'):
Just let the DatePicker control format it to your desired output format ('dd-MM-yyyy'):
new sap.ui.commons.DatePicker("date2",{
width: "10em",
value: {
path: "myModel>/dateValue",
//the format information
type: new sap.ui.model.type.Date({pattern: "dd.MM.yy"})
}
});
希望这会有所帮助!
这篇关于表SAPUI5中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!