Skip to Content

Date Format changes the value of the Day


My oData service provides data in the below format:


This date is formatted in my application as below:

// Set the Document Created date
  var oAttrCrdttm = new sap.m.ObjectAttribute({id:"Crdttm",
  visible: true,
  title: "Created",
  text: {path: "WiCd",
    formatter: function(date){
              var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern: "MM-dd-yyyy"});
              date1 = oDateFormat.format(new Date(date));
              return date1
             }else {
              return null;
          } } },
  active: false });

But the output shows below:

After formatting the date it changes the day by one day, not sure what could be the reason.

Thank you for your time and help

date.jpg (4.7 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jan 02, 2015 at 11:30 PM

    Issue is resolved:

    As the date in oData Service was <d:WiCd>2014-12-12T00:00:00</d:WiCd> as the time in the date is 00:00:00 due to which, format on DateFormat converts it to 2014-12-11.

    Resolved this by stripped the time part in the date field using below code:

    date = date.split("T");

    So that the date part is only used for formatting:

    This worked in my scenario, can suggest if there is a better solution for the same.

    Thanks all for your Views

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.