1

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.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
ArslaneM
  • 31
  • 1
  • 5
  • Does this answer your question? [OData Edm.DateTime - How to Display Date Only](https://stackoverflow.com/questions/50210037/odata-edm-datetime-how-to-display-date-only) – Boghyon Hoffmann Sep 09 '20 at 00:13

2 Answers2

3

Here you go:

new sap.m.ObjectIdentifier({
  width : "100%" ,
  title : "{ path: 'DocDate' , type: 'sap.ui.model.type.Date', formatOptions: {pattern: 'yyyy-MM-dd'} }" 
});
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Lumpenstein
  • 1,250
  • 1
  • 10
  • 27
1

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());
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Tilak Raj
  • 11
  • 2