Search code examples
sapui5

sap.ui.core.format.DateFormat.format give wrong date


For one Client, and only when switch the browser to english, the following code:

convertTimeToDate: function(dateobj) {


            if ((dateobj == undefined) || (dateobj == null)) {
                return "";
            }


            var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({
                pattern: "dd. MMM YYYY"
            });

            var dateFormatted = dateFormat.format(dateobj);

           return dateFormatted;
},

returns when inputing the highdate '9999-12-31' the datestring '31. Dec 10000' what could be the problem? It is reproducible only on the maschine of this one person, but for her it happens ALWAYS.


Solution

  • I was plagued by the same 10k date. My pattern was {pattern: 'MMMM Y'}. Changing it to {pattern: 'MMMM yyyy'} solved the problem. I cannot find any documents on the difference between 'Y' and 'y' though.