Skip to Content
avatar image
Former Member

Date is not formatting correctly in Datepicker

Hi Experts,

I am using sap.m.DatePicker in my application and I am binding the value property for my datepicker as below.

new sap.m.DatePicker({value:{path : '/bindDate', type : 'sap.ui.model.type.Date', formatOptions:{pattern : 'dd/MM/yyyy', strictParsing : true}}})

It is working fine and the date which user is entering is checked for validation and checked properly. But it is failing in only one condition when the user enters the date as "02102016" or "020116". In this condition the date is converted to "10/02/2016" instead of "02/10/2016".

Could you please help to rectify these and to convert the date in required format.

Thanks,

Sanjay Aswani

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 15, 2017 at 11:04 AM

    Hi Saurabh,

    Thanks for the answer. But I got the issue. I am currently using SAP UI5 version 1.38.5 and in this version it is a bug. But in latest version the date picker is working as expected.

    Thanks & Regards

    Sanjay Aswani

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 14, 2017 at 11:01 AM

    With the below code I tried entering 02102016 and 021016 in the DatePicker field, on pressing Enter I get the date 02/10/2016.

    <DatePicker value="{path: 'HireDate', type: 'sap.ui.model.type.Date', 
    formatOptions: {
    pattern: 'dd/MM/yyyy'
    }}" />
    Add comment
    10|10000 characters needed characters exceeded