In UI5, my OData is returning the date in the following format:
Mon Apr 09 2018 01:00:00 GMT+0100 (GMT Daylight Time)
I would like to format it to: 09/04/2018
I have tried the following without any results:
<Text text="{
path: 'MyoDataService>ExecuteDay',
type: 'sap.ui.model.type.Date',
formatOptions: {
pattern: 'yyyy/MM/dd'
}
}"/>
Another example I have tried and It is not working neither:
<Text text="{
path:'MyoDataService>ExecuteDay',
type: 'sap.ui.model.type.Date',
formatOptions: {
source: {
pattern: 'yyyy-MM-ddTHH:mm:ss'
},
pattern: 'dd MMM yyyy'
}
}" />
The controller where the model gets created looks like this:
onInit: function() {
var sServiceUrl = "http://myurl/myservice";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl,true);
var oJsonModel = new sap.ui.model.json.JSONModel();
oModel.read("/MyEntitySet", null, null, true, function(oData, response) {
oJsonModel.setData(oData);
});
this.getView().setModel(oJsonModel, "MyEntitySet");
},