Search code examples
dateformattingodatasapui5

Formatting a "/Date(timestamp)/" value in UI5


I have a similar question like this here or here. I am using an XML view, too. With this code

<Text text="{ path: 'model1>CHANGE_DATE' }" />

I get the following response from the OData (V2) service:

/Date(1671944676355)/

When I try

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

I receive the error message:

sap-ui-core-dbg.js:30928 Uncaught TypeError: oDate.getTime is not a function

Do you have any idea why the formatting did not work?


Solution

  • Converting to ODataModel solved this issue.