cancel
Showing results for 
Search instead for 
Did you mean: 

EDM.Time is not converting in SAPUI5

vadrevu_kk
Participant
0 Kudos

Dear All,

I am receiving Time data from SAP in EDM.Time which is not converting in SAPUI5.

Could you please help me.

Thanks,

VKK.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

This message was moderated.

raeijpe
Contributor
0 Kudos

Hi Kiran,

Please look at the blog Working with OData Dates and Times from John Patterson on SCN.

He explain very well how you must use date/time from OData into SAPUI5 applications.

With regards,

Robert Eijpe

initiator of sapui5.org

vadrevu_kk
Participant
0 Kudos

Hi Robert,

I have read the blog, but my question is "do we have any SAP UI5 predefined function whcih can convert from edm.time to desired time format pattern"?

Thanks,

Kiran.

kammaje_cis
Active Contributor
0 Kudos

Hi Kiran,

It is mentioned in the blog Robert mentioned.

Copying from the blog,

In the below statement, select from the pattern elements mentioned in the blog.

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


var timeStr = timeFormat.format(new Date(DepartureTime.ms + TZOffsetMs));  //11:00 AM 

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

Let us know if you are looking for something else?

Thanks

Krishna


vadrevu_kk
Participant
0 Kudos

Hi Kishore,

As SAP knows that time will come from SAP as edm.time, why they did not provide direct control to change this instead of parsing with our own code?

Else do we need to get time in string format instead of edm.time?

Thanks,

Kiran.

kammaje_cis
Active Contributor
0 Kudos

May be I did not understand your question.

The APIs I pasted are given by SAPUI5.

So where did you expect them to give the control?

Former Member
0 Kudos

Hi Krishna,

I think what Kiran wants is direct type binding for time object. Is there any way to do that directly without formatter functions.

For example :

If I make the type as Date for ZzpstartDat, the formatting is automatically taken care of but maintaining a type for time like sap.ui.model.type.Time doesn't work.

<Text text="{path : 'ZzpstartDat', type : 'sap.ui.model.type.Date'}" />


<Text text="{path : 'ZzpstartTime', formatter : '.timeFormatter'}" />

//This doesn't work::
<Text text="{path : 'ZzpstartTime', formatter : '.sap.ui.model.type.Time'}" />