on 2015 Aug 11 11:51 AM
Hi All,
I created a table with XML view.
This is how i have binded.
<items>
<ColumnListItem>
<cells>
<Text
text="{empModel>Empno}" />
<Text
text="{empModel>Fname}" />
<Text
text="{empModel>Lname}" />
<Text
text="{empModel>Addrs}" />
<Text
text="{empModel>Desgn}" />
<Text
text="{empModel>Dob}" />
</cells>
</ColumnListItem>
</items>
But my date format which is coming from gateway is in this format "2015-05-05T05:13:19.3167890".
I want to display it as 05-05-2015.
I also have a datepicker and in that datepicker date format is not selected in this format. So basically how i can perform the POST operations?
I am a beginner so if possible attach a simple code for reference.
Thanks in advance.
Request clarification before answering.
Hi,
you can try 2 options
1. use type and formatOptions
SAPUI5 Explored
2. use formattrer function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu,
please, try that
Code in view
<Text text="{path: 'empModel>Dob',
formatter: '.formatDate'}"
/>
function in controller:
formatDate : function(v) {
jQuery.sap.require("sap.ui.core.format.DateFormat");
var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "dd-MM-YYYY"});
return oDateFormat.format(new Date(v));
}
Regards,
Raman
Well, you forgot to specify the input pattern Also, you used brackets surrounding the model field you are binding, but this is incorrect too (you are already binding)
Change it to
<Text text="{
path: 'empModel>Dob',
type: 'sap.ui.model.type.Date',
formatOptions: {
source: {
pattern: 'yyyy-MM-ddTHH:mm:ss.AAAAAAA'
},
pattern: 'yyyy/MM/dd'
}
}" />
You probably did something wrong then... works for me in this working example: Edit fiddle - JSFiddle
Since your example date was "2015-05-05T05:13:19.3167890", I assumed the last 7 digits were milliseconds.
But obviously, milliseconds can only be maximum of 3 digits (hence the milli) so i'm not sure what those last 7 digits are. If you look at the example I just provided, you'll see a correct date
You are welcome:)
UI5 uses this syntax for binding. Dot means a local function/type.
Read more SAPUI5 SDK - Demo Kit
Hi Robin,
From OData service I am receiving the date in following format:
/Date(1354665600000)/"
and I am binding it to sap.ui.commons.DatePicker.
So what should be the source pattern in my case?? I dont want to use formatter function as it is not updating the changed values in model (I am using json model).
Thanks and Regards,
Sagar
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.