Skip to Content

SAPUI5 Date Conversion: getDateTimeInstance() - Different Behavior for Different Languages

Sep 18, 2017 at 01:19 PM


avatar image

Dear All,

I am doing date format using this function sap.ui.core.format.DateFormat.getDateTimeInstance({ pattern: "YYYY-MM-ddTHH:mm" });.

converting to string from date object.

The date format is working fine in "EN" but it is returning wrong value in "DE".

Reproduceable in DE . Change your browser language to DE. Close and open browser. use bellow link to see the issue,output

The date input value is 01.01.2021 but its returning 01.01.2020 in "DE"

I did debug F11. In DateFormat-dbg.js bellow highlighted method is called and when highlighted line changes the date value.

the line is calling UniversalDate-dbg.js file is getting called.

In UniversalDate-dbg.js highlight if else block is executing for different language.

data value 01.01.2021,02.01.2021,03.01.2021 is not working 04.01.2021 is working Because else if (oDate < oFirstDay) is like (04.01.2021 < 04.01.2021).

Check for var oFirstDay

else block is executing for EN.

Best Regards,

Sathish Mani

dateformat.png (146.8 kB)
odataformatdbg.png (314.6 kB)
universaldate.png (204.3 kB)
calender.png (21.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Satish Kumar Mani
Sep 19, 2017 at 02:20 PM

Hi All,

The issue has beed fixed by adding Parameter UTC:false.

sap.ui.core.format.DateFormat.getDateTimeInstance({ pattern: "YYYY-MM-ddTHH:mm" ,UTC:false});

Best Regards,

Sathish Mani

10 |10000 characters needed characters left characters exceeded