ArslaneM
ArslaneM

Reputation: 41

How to Format the Date in SAPUI5?

How to format the Date and time in sapui5 application. Formatter option is not working. Please suggest some idea. Shared the tried code also.

my code :

new sap.m.ObjectIdentifier({  width : "100%" ,
        title : "{DocDate}",
        type: new sap.ui.model.type.DateTime({pattern: "yyyy-MM-dd"})
 
    }) 

result : result

I need result like this : 2020-09-08

If anyone has an idea or a suggestion, I'd be more than thankful if you let me know.

Upvotes: 2

Views: 10820

Answers (2)

Tilak Raj
Tilak Raj

Reputation: 11

To format a date in sapui5 this works as well. Check in console.

// DateFormat required from the module "sap/ui/core/format/DateFormat"
DateFormat.getDateInstance({pattern: "yyyy-MM-dd"}).format(new Date());

Upvotes: 1

Ruckert Solutions
Ruckert Solutions

Reputation: 1301

Here you go:

new sap.m.ObjectIdentifier({
  width : "100%" ,
  title : "{ path: 'DocDate' , type: 'sap.ui.model.type.Date', formatOptions: {pattern: 'yyyy-MM-dd'} }" 
});

Upvotes: 4

Related Questions