My default date setting in Fiori launchpad is "dd.MM.yyyy, HH:mm"
. Whenever I get the date from the date picker placed in view, I am getting the date in the above format.
Now I want to send this date to backend through ODataModel
which generally accepts date in XML date format (e.g. "2014-12-30"). I tried the below code, but it did not work.
var fromDate = this.byId("fromDate").getValue(); // "30.12.2014, 10:36"
var oDateFormat = DateFormat.getDateTimeInstance({ pattern : "yyyy-MM-dd" }); // DateFormat required from "sap/ui/core/format/DateFormat"
var subFromDate = oDateFormat.format(new Date(fromDate)); // "0NaN-NaN-NaN".
When I check in debugger mode, the value in subFromDate is "0NaN-NaN-NaN"
. Please provide your valuable suggestions.