on 2022 Mar 24 2:29 PM
Hi All
I have a date field on XML view and its showing date format correctly , when i am picking date using date calendar.
However , when i am placing same date by using Odata from backend system, its showing complete date with time and zone.
Listed below is XML View and Controller codes:
Controller , is showing date as "Thu Mar 01 2018 05:00:00 GMT+0500 (Pakistan Standard Time)" whereas I want to show in format 01.03.2018
<Label text="Date of Joining" required="true"/>
<DatePicker name="Zdoj" value="{path: 'Zdoj', type: 'sap.ui.model.type.Date', formatOptions: {pattern: 'dd.MM.yyyy', strictParsing: true , UTC: true}}" id="Zdoj_id"
enabled="{= ${viewModel>/mode} === 'edit'? false: true}" visible="true"/>
var oDate = new sap.ui.model.type.Date({source: {}, pattern: "dd.MM.yyyy"});
oDate = oData.Zdoj;
that.getView().byId("Zdoj_id").setValue(oDate);
Request clarification before answering.
Able to resolve the issue , using the following code in controller of view. Closing the thread.
var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern :"dd.MM.yyyy"});
var oDate = dateFormat.format(oData.Zdoj);
that.getView().byId("Zdoj_id").setValue(oDate);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.