Y
Y
Yul_kv2020-03-28 23:45:58
SAP
Yul_kv, 2020-03-28 23:45:58

/Date(1671944676355)/ to dd.mm.yyyy?

I am using Worklist.view.xml and receive /Date(1671944676355)/

Text text="{Exdat}"

When I try
Text text="{path: 'Exdat',
type: 'sap.ui.model.type.Date ',
formatOptions:{pattern:'dd/MM/YYYY'}
}"
I receive the error message. How correctly convert date from JSON MODEL in such format dd/MM/YYYY?

Also I receive time in such format PT8H19M11S. I need to convert it in format hh:mm:ss?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yul_kv, 2020-03-31
@Yul_kv

I solved my problem:
In Worklist.view.xml I use formatter function:
Text text="{path:'Exdat', formatter: '.formatter.formatDate'}"
Then in formatter.js I write
formatDate: function (sValue) {
var date = new Date(parseInt(sValue.substr(6)));
var oFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern: "dd.MM.YYYY"});
return oFormat.format(date);
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question