cancel
Showing results for 
Search instead for 
Did you mean: 

Calendar date format

Former Member
0 Kudos

Helo, I have i question how to change calendar date format, for example now when i'm press on date i got 2014 May 28 how can I change that when i'm press on date i  will get 2014-05-28?

Accepted Solutions (1)

Accepted Solutions (1)

nabheetscn
Active Contributor
0 Kudos

Hi Edgaras

For date formatting you can implement below mentioned code. Check the highlighted function

template : new sap.ui.commons.TextView( {                                                                              textAlign : 'Left'}) .bindProperty("text",  {path: <field_name>,formatter: function(oValue){

if (oValue) {  var d = new Date(oValue);                    

  return sap.ui.core.format.DateFormat.getDateInstance( {style:"full", pattern: "yyyy-MM-dd"}).format(d); }}} ),           


Nabheet

Former Member
0 Kudos

Thx, its working now, but i'm facing another problem, in console i see that  date format now looks 2014-05-27T00:00:00 how can i remove time at end of date ? Sry for my bad ENG

Former Member
0 Kudos

Hi Edgaras,

You could store the Date value( example -  2014-05-27T00:00:00) in a variable and using JavaScript you may get the date value using the Sub String function.

var str = "2014-05-27T00:00:00";

    var result = str.substr(0, 10);

Here,

0  -  indicates starting position i.e. '2'

10 - indicates that 10 characters should be considered i.e. from '2' to '7', from the datevalue.

Let me know, if you need further assistance.

Regards,

Suraj Kumar

Answers (0)