Reputation: 1663
Openui5 version working on: 1.38.4
wk_start_ts=new sap.m.DateTimeInput({type:"DateTime",
layoutData: new sap.ui.layout.GridData({linebreak: false,span: "L6 M6 S6"}),
dateValue: new Date(1468845873851),
valueFormat: "dd/MM/yyyy HH:mm:ss",
visible : true,
displayFormat: "dd/MM/yyyy HH:mm"}).placeAt("body");
var oButton1 = new sap.ui.commons.Button({
text : "Button",
tooltip : "This is a test tooltip",
press : function() {alert(wk_start_ts.getValue());}
});
oButton1.placeAt("body");
For example :
Expected data bound by default is 18/7/2016 18:56
Expected output is 18/7/2016 18:56
Actual Output : 07/18/2016 6:56 PM
Note:
If I change value and then press button then I get expected date value.
Here is an example bin (https://jsbin.com/doxoro/edit?js,output).
Added a screenshot from browser tested upon i.e. Google Chrome
Upvotes: 0
Views: 1406
Reputation: 6001
I debugged a bit and it appears that it processes the settings by for (property in settings) clause. So in your particular fragment dateValue is processed before any formatting options. And I would suggest to place dateValue at the end of the settings object:
wk_start_ts=new sap.m.DateTimeInput({type:"DateTime",
layoutData: new sap.ui.layout.GridData({linebreak: false,span: "L6 M6 S6"}),
valueFormat: "dd/MM/yyyy HH:mm:ss",
visible : true,
displayFormat: "dd/MM/yyyy HH:mm",
dateValue: new Date(1468845873851)
}).placeAt("body");
var oButton1 = new sap.ui.commons.Button({
text : "Button",
tooltip : "This is a test tooltip",
press : function() {alert(wk_start_ts.getValue());}
});
oButton1.placeAt("body");
Upvotes: 1