I am trying to format this Time coming from ODATA, in the XML it looks like this: PT00H00M00S
I tried first creating a function I found online: Seems promising but.....I wans't sure how to use in in the VIEW.XML, is somebody could advise I would appreciate. I just started with UI5.
return Controller.extend("zTESTJK1.zTESTJK1.controller.Main", {
Time: function (val) {
if (val) {
val = val.replace(/^PT/, '').replace(/S$/, '');
val = val.replace('H', ':').replace('M', ':');
var multipler = 60 * 60;
var result = 0;
val.split(':').forEach(function (token) {
result += token * multipler;
multipler = multipler / 60;
});
var timeinmiliseconds = result * 1000;
var timeFormat = sap.ui.core.format.DateFormat.getTimeInstance({
pattern: "KK:mm:ss a"
});
var TZOffsetMs = new Date(0).getTimezoneOffset() * 60 * 1000;
return timeFormat.format(new Date(timeinmiliseconds + TZOffsetMs));
}
return null;
}