I'm using the sap.m.ObjectStatus as part of my status display on a given agregated list:
in view.js:
var curstat = new sap.m.ObjectStatus({
//text: "{CountDate}",
//text: oController.formatDate('{CountDate}'),
state: "Success",
text: {
parts:[{path:'CountDate'}],
formatter: 'oController.formatterCountDate'
}
});
snippet in the controller.js, the format of the CountDate value is, yyyy-mm-ddT00:00:00. goal is to remove the time part leaving only YYYY-MM-DD. I don't get any exception thrown and the date does show just not in the format I want. I feel I'm close but just can't get figure out what I may be over looking. Thanks in advance for the help.
formatterCountDate:function(t) {
try {
var d = new Date();
var T = new sap.ui.model.type.Date( {
source : {
pattern : "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
},
pattern : "yyyy,MM,dd",
style : "medium"
});
d = T.formatValue(t, "string");
var D = new Date(d);
return D
}//try
catch(error) {
alert(error.message);
}
},
Request clarification before answering.
Hi Jay, can you try with the below code.
Also make sure your CountDate propery in OData model has Edm.DateTime datatype.
formatterCountDate : function (value) {
if((value!=null) && (value!="0000-00-00"))
{
if (value) {
var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "yyyy,MM,dd"});
return oDateFormat.format(new Date(value));
}
else { return value; }
}
else return "";
}
Let me know if you face any issues.
--Naveenraj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.