1
votes

currently, I'm trying to add some date parameter to my add

from my backend I get

/Date(1525521600000+0000)/

I tried some methods like

    <Text text="{path: 'ValueDate',
                type: 'sap.ui.model.odata.type.DateTime',
                formatOptions: {
                style: 'medium'                                                         
                       }
                }"/>

But this gives me no Output

If i try

<Text text="{path: 'ValueDate',
                type: 'sap.ui.model.odata.type.Date',
                formatOptions: {
                style: 'medium'                                                         
                       }
                }"/>

I simply get out

enter image description here

But I want an Output like dd/MM/yyyy

2

2 Answers

2
votes

Binding:

 text="{
        path: 'ValueDate',
        formatter: '.formatter.dateFormatter'
    }"

Formatter Function

 function dateFormatter (jsonDateString){ 
   return new Date(parseInt(jsonDateString.replace('/Date(', '')));
}
1
votes

If you don't get a standard OData Date Object, you have to do this via the formatter function of SAPUI5:

text="{
    path: 'ValueDate',
    formatter: '.formatter.date'
}"

in the formatter.js file you have to implement a "date" function and convert it to your desired value. For more information on formatters: https://openui5.hana.ondemand.com/1.38.5/#docs/guide/0f8626ed7b7542ffaa44601828db20de.html