cancel
Showing results for 
Search instead for 
Did you mean: 

How the DateFormat works for Edm.datetime in SAPUI5?

Jayakrishnan
Active Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

ptw044
Explorer

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 } }"/>

Jayakrishnan
Active Participant
0 Kudos

Yea, it works. Thank you.

My Code:

	var tableNotificationCell4 = new sap.m.Text({
					text: {
						path: "Erdat",
						type: "sap.ui.model.type.Date",
						formatOptions: {
							pattern: "dd:MM:yyyy",
							UTC: true
						}


					}
				});

Answers (0)