0

I am trying to use the dates from an OData service V2, the format of the dates looks like this /Date(1402166783294)/

The following code does not work:

OData source

"Exdat": "/Date(1569962730000)/",

View

<cells>
  <ObjectIdentifier title="{
    path:'Exdat',
    type: 'sap.ui.model.type.Date',
    formatOptions: { pattern: 'yyyy/MM/dd' }
  }" />
</cells>

Is there any way for me to go through all the dates in the OData source and map those within a table?

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
  • The question is; why do you have to deal with the `/Date()/` format in the first place? Looks like the application is fetching the entities with a plain `JSONModel` or `XHR` instead of an `ODataModel`. – Boghyon Hoffmann Dec 05 '19 at 12:20
  • Does this answer your question? [How to Add Date / Time from OData Service Correctly to UI?](https://stackoverflow.com/questions/47593990/how-to-add-date-time-from-odata-service-correctly-to-ui) – Boghyon Hoffmann Dec 05 '19 at 12:20
  • { "__metadata": { "id": "Executions(Exeid='20190424070000',Intid='PROTOC1001')", "type": "com.epam.backend.im.Execution", "uri": "Executions(Exeid='20190424070000',Intid='PROTOC1001')" }, "Exdat": "/Date(1569962730000)/", "Exeid": "20190424070000", "Exha1": "EXPIRED", ........ } } }, that's the data from backend I have. – user2742080 Dec 05 '19 at 14:59
  • Yes, that's the typical OData V2 response. Now, when binding the property with an `ODataModel`, the internal lib _datajs_ will convert the `/Date(...)/` value to a standard JS date-object [(src)](https://github.com/SAP/openui5/blob/bc19b05e6a3149983fcb469a63a75141e3deec96/src/sap.ui.core/src/sap/ui/thirdparty/datajs.js#L7258-L7299). Let us know if the [linked answer](https://stackoverflow.com/a/47603778/5846045) tries to solve the same issue. If not, enhance the question with more details by providing an [mvce](https://stackoverflow.com/help/minimal-reproducible-example). – Boghyon Hoffmann Dec 05 '19 at 16:07

0 Answers0