Date Control issue

Posted by: mayur.purandare on 27 July 2020, 9:14 pm EST

    • Post Options:
    • Link

    Posted 27 July 2020, 9:14 pm EST

    Set Date as : 2-08-2020 and select Tab or move to any other control.

    After selection of tab button or cursor move, date is automatically changed to 08-02-2020.

  • Posted 28 July 2020, 9:26 pm EST - Updated 3 October 2022, 11:53 pm EST

    Hi Mayur,

    I am not sure which control you are using, so I am taking C1DatePicker as reference for discussion. If you are using any other control or using C1DatePicker inside another control then please specify.

    To replicate the posted issue, we tested C1DatePicker with default values to all properties but could not see the behavior you mention. See attached video of the default C1DatePicker.

    Therefore, in order for us to assist you, please share more details about your usage of the control.

    Thanks,

  • Posted 28 July 2020, 11:00 pm EST

    Dear Team,

    I am keeping my date format as dd/mm/yyyy. and when I edit it as 02/3/2020 it becomes 03/02/2020.

    I have attached sample solution also for this issue.

  • Posted 28 July 2020, 11:44 pm EST

  • Posted 29 July 2020, 6:09 pm EST - Updated 3 October 2022, 11:53 pm EST

    Hi Mayur,

    Got it, thanks.

    The behavior you are observing could be because of incompatibility with the CurrentCulture.

    C1DatePicker uses CurrentCulture to convert value to string. If CurrentCulture uses date format incompatible with the CustomFormat, you can see such issues. I suggest to check what is the actual value of the CurrentThread.CurrentCulture and set it to something appropriate for the specified format.

    All the ComponentOne controls honor the FrameworkElement.Language property value. If it is not set, controls will use the default culture “en-US”.

    Also, if your application explicitly sets Thread.CurrentThread.CurrentCulture property value, make sure that you set Language property for the root visual in your application to the same value

    For details you can read carefully the readme for build 271:



    Also, refer the following post: https://www.grapecity.com/blogs/language-and-currentculture-in-silverlight-and-wpf/

    With regards,

    Ruchir

  • Posted 30 July 2020, 10:00 pm EST

    Dear Team,

    I have shared the sample application. If you can check the code, I am not changing any default culture only I want my date format as dd:mm:yyyy.

    Please check the sample provided I have not changed the culture still it changes from 02/3/2020 it becomes 03/02/2020.

  • Posted 4 August 2020, 12:08 am EST

    Hi Mayur,

    As I see that you are providing a custom format for Date i.e “dd/MM/yyyy”. Therefore the date 02/3/2020 is not valid as per this custom format and during validation it will be considered as “MM/d/yyyy” by the .Net Framework and hence the behavior.

    However if you want to use the month with/without zeroes you can use dd/M/yyyy format.

    I hope it helped.

    Regards,

    Basant

  • Posted 4 August 2020, 6:46 pm EST

    Dear Team,

    If I used the format as dd/m/yyyy

    Query:

    1. While displaying it will display 02/3/2020 where as my app needs the format as dd/mm/yyyy.

    2. Now if kept the format as dd/m/yyyy and displayed date is 03/9/2020 now if I edit the date as 2/9/2020 then also it changes to 09/2/2020 which is not correct.

  • Posted 4 August 2020, 10:58 pm EST

    Hi Mayur,

    It is recommended to input the date with same format as specified in CustomFormat in C1DatePicker. Therefore if the inputted date format doesn’t match with provided CustomFormat then the provided date will be parsed in the default date format by .Net Framework. And that parsed date object will be converted in the CustomFormat by C1DatePicker.

    For example if your CustomFormat is dd/mm/yyyy then you can only input date as 02/03/2020 and not as 02/3/2020 because it will be considered as MM/d/yyyy by the .Net Framework.

    Similarly as you are saying 2/9/2020 is changed to 09/2/2020. This is because 2/9/2020 is considered as m/d/yyyy by .Net Framework which doesn’t matches with the provided custom format dd/M/yyyy.

    So, It is suggested to input date with correct format as specified in Custom format because parsing dates is specific to .Net framework.

    Regards,

    Basant

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels