Skip to Content

Date mismatch in SAP UI5 Application

I have an Date Picker in SAP UI5 application. actual server is in Australia. When I create any record in IST time, it is working fine. But when an user tries to create any record in Australia, the Date value is increment to +1. That is 31 coming as 32. Do i need to consider the timeZone?

Regards Saanvi S

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Sep 11, 2017 at 12:25 PM

    Hi Saanvi,

    The Data Picker date object includes the time zone due to which you are getting the issue.

    Approach1: use property "valueFormat" e.g 'YYYYMMDD' and read the value by the method this.getView().byId("iddate").getValue() and pass this value to OData service.

    Approach2: you can use below code as formatter function to remove the time zone from the Data Picker date object.

    var dateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({
    		pattern: "yyyy-MM-ddTKK:mm:ss"
    	});
    	return dateFormat.format(d);
    

    Thanks,

    NP

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 11, 2017 at 12:10 PM

    Yes, you need to consider the timezone. Check the usage of the property "valueFormat" for this purpose.

    Regards,
    Sharath

    Add comment
    10|10000 characters needed characters exceeded