cancel
Showing results for 
Search instead for 
Did you mean: 

Format time value from odata records

Former Member
0 Kudos

Hi All,

I am facing one critical issue to convert time format which is coming from SAP Odata model. I am able to format the value with the below code if I give static value

var DepartureTime = {__edmType: "Edm.Time", ms: 39600000};

   var timeFormat = sap.ui.core.format.DateFormat.getTimeInstance({pattern: "kk:mm"});

   var TZOffsetMs = new Date(0).getTimezoneOffset()*60*1000;

   var timeStr = timeFormat.format(new Date(DepartureTime.ms + TZOffsetMs));

   var parsedTime = new Date(timeFormat.parse(timeStr).getTime() - TZOffsetMs);

   console.log('Time = ' +timeStr);

I am unable to get that value from odata to convert into Time format. I am getting the value as [object Object]. Here is the screen shot of values I am getting from SAP Odata model. Can you please helo how we can retrieve the value from "DepartureTime"

Regards,

Suresh

Message was edited by: Michael Appleby (typos)

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member293602
Active Participant
0 Kudos

Hi Suresh,

just put your logic in a formatter function. This formatter can then be used with the property binding. You can find the details in OpenUI5 SDK - Demo Kit. For a more complete description you can check http://scn.sap.com/community/developer-center/front-end/blog/2013/04/28/working-with-odata-dates.

Regards, Frank