Skip to Content

How the DateFormat works for Edm.datetime in SAPUI5?

Hi Everyone,

I am working on Custom SAPUI5 App development. In our application we need to display the date in the Table. It is coming in a Edm.DateTime format from OData Service.

By referring the SAPUI5 Explored Website i used format options to do formatting. But it is not getting reflected in the SAPUI5 Table.

I used like this in my sapui5 table code

<Text text="{ path: '/Erdat', type: 'sap.ui.model.type.DateTime', formatOptions: { style: 'short' } }"/> //SAPUI5 table Code

But if i use simply as Erdate without specify the formatting options , it displays the value like this

Fri Mar 07 2003 05:30:00 GMT+0530 (India Standard Time)//without Format
<d:Erdat>2003-03-07T00:00:00</d:Erdat>// in gateway Client


Type="Edm.DateTime" // type in metadata

Please refer the below image for more info:

Please help me to solve this.

Thank you,

Regards,

JK.

dateformat.png (17.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Jul 26, 2018 at 06:12 AM

    Hi,

    Use below code to format date.

    <Text text="{ path: 'main>CreatedAt', type: 'sap.ui.model.type.Date', formatOptions: { pattern: 'dd:MM:yyyy', UTC: true } }"/>

    Add comment
    10|10000 characters needed characters exceeded