Reputation: 384
I have a view that goes as follows:
<f:content>
<core:Title text="Student" />
<Label text="Name" />
<Text text="{fullName}" />
<Label text="Date of Birth" />
<Text text="{dob}" />
The {dob} is the value that is being fetched from the Database. When the value is displayed it is displayed as:
Date of Birth :2015-12-30T00:00:00.000Z
I want it to be displayed only 2015-12-30.
Help!
Upvotes: 0
Views: 2982
Reputation: 4225
<Text text ="{path:'dob', type:'sap.ui.model.type.Date', formatOptions : { style:'medium', UTC: true}}"/>
This is cleaner solution according to me, unless you have special formatting of Date apart from what SAP provides.
Read more about sap.ui.model.type.Date
& for
date format options explore here.
Upvotes: 1
Reputation: 31632
You should be able to define a formatter this way:
<Text text = "{ path: 'dob', formatter: 'my.Formatter.formatDate' }" />
And in js:
jQuery.sap.declare("my.Formatter");
my.Formatter = {
formatDate : function (value) {// value is the date
return "xx"; // return the formatted date
}
};
Upvotes: 0