format date object to string
var oDate = new Date('2023-12-31T00:00:00'); //format date object to string var oDateFormat = new sap.ui.model.type.Date({ UTC: false, style: "medium" }); oDateFormat.formatValue(oDate, "string"); //Expected output: 31.12.2023
var oDate = new Date('2023-12-31T00:00:00'); //format date object to string var oDateFormat = new sap.ui.model.type.Date({ UTC: true, style: "medium" }); oDateFormat.formatValue(oDate, "string"); //Expected output: 30.12.2023
format date string with yyyy-MM-dd format to locale format
var sDate = "2023-12-31"; //format date string with yyyy-MM-dd format to locale format var oDateFormat = new sap.ui.model.type.Date({ style: "medium", source: { pattern: "yyyy-MM-dd" } }); oDateFormat.formatValue(sDate, "string"); //Expected output: 31.12.2023
format date object to HH:mm string
var oDate = new Date('2023-12-31T00:00:00'); //format date object to HH:mm string var oDateFormat = new sap.ui.model.type.Date({ UTC: false, style: "medium", pattern: 'HH:mm' }); oDateFormat.formatValue(oDate, "string"); //Expected output: 00:00
var oDate = new Date('2023-12-31T00:00:00'); //format date object to HH:mm string var oDateFormat = new sap.ui.model.type.Date({ UTC: true, style: "medium", pattern: 'HH:mm' }); oDateFormat.formatValue(oDate, "string"); //Expected output: 23:00